Make lines visible or invisible

Is there a way (in a script) to make lines visible or invisible when you open a figure already existing (using openfig())? Thanks

Antworten (2)

KSSV
KSSV am 20 Okt. 2016

0 Stimmen

plot(rand(10,1))
set(gcf,'visible','off')
set(gcf,'visible','on')
Mischa Kim
Mischa Kim am 20 Okt. 2016
Bearbeitet: Mischa Kim am 20 Okt. 2016

0 Stimmen

There is:
t = 0:0.1:10;
y = sin(t);
figure
h1 = plot(t,y);
set(h1,'Tag','Line1')
hold on
h2 = plot(t,y.^2);
set(h2,'Tag','Line2')
savefig('MySavedPlot.fig');
close(gcf)
clear
fig = openfig('MySavedPlot.fig');
axesObjs = get(fig, 'Children');
dataObjs = get(axesObjs, 'Children');
set(findobj(dataObjs,'Tag','Line2'),'LineStyle','none');

4 Kommentare

Elena
Elena am 20 Okt. 2016
It works also if you have more than one line? Because I have a graph with 14 lines and I would like to make visible all the combination of 2 lines and save all the "2 line graphs" as *.emf file.
Mischa Kim
Mischa Kim am 20 Okt. 2016
Yes, it is: tag all 14 lines so you can find them again using the findobj command. See updated script above.
Devlin Murray
Devlin Murray am 30 Sep. 2019
Is there a way to do this but still have the original color show up in the legend. I want to have a correct legend corresponding to conditions but if the plot doesn't meet all of them I don't want to plot it.
camicat
camicat am 5 Feb. 2020
@Devlin Murray were you able to figure out how to do what you asked? I'm trying to do the same thing, thank you!

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Hilfe-Center und File Exchange

Produkte

Gefragt:

am 20 Okt. 2016

Kommentiert:

am 5 Feb. 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by