Azzera filtri
Azzera filtri

Make lines visible or invisible

151 visualizzazioni (ultimi 30 giorni)
Elena
Elena il 20 Ott 2016
Commentato: camicat il 5 Feb 2020
Is there a way (in a script) to make lines visible or invisible when you open a figure already existing (using openfig())? Thanks

Risposte (2)

KSSV
KSSV il 20 Ott 2016
plot(rand(10,1))
set(gcf,'visible','off')
set(gcf,'visible','on')

Mischa Kim
Mischa Kim il 20 Ott 2016
Modificato: Mischa Kim il 20 Ott 2016
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 Commenti
Devlin Murray
Devlin Murray il 30 Set 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 il 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!

Accedi per commentare.

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by