Azzera filtri
Azzera filtri

How can I keep figures invisible when toggling between axes?

4 visualizzazioni (ultimi 30 giorni)
If I create figures using the following code
for fig=1:2
figure('papertype','A4','paperorientation','portrait','Visible','Off')
for sp=1:6
ax{fig,sp}=subplot(3,2,sp,'parent',fig);
end
end
I can then toggle between the subplots using axes, e.g., to get to subplot 4 on figure 2 I use
axes(ax{2,4})
But this makes the figure visible. Does anyone know if there's a way to keep it invisible please?
Thanks in advance for your help! Jen

Risposte (2)

Rik
Rik il 15 Nov 2017
You can either use the obvious solution/workaround of calling set(gcf,'Visible','off') immediately after that line, or just avoid that line in the first place. Just about every function I can think of will accept a target axis instead of using the current axis as default.

Walter Roberson
Walter Roberson il 15 Nov 2017
Calling axes() should not cause the figure to become visible unless the axes() call is creating a new figure.
Instead of calling axes to make an axes the current axes, you can
for fig=1:2
figs(fig) = figure('papertype','A4','paperorientation','portrait','Visible','Off');
for sp=1:6
ax{fig,sp} = subplot(3, 2, sp, 'parent', figs(fig));
end
end
and later
set(figs(2), 'CurrentAxes', ax{2, 4})
But as Rik suggests, you can mostly rewrite to pass an axes in to graphics commands, either as the first parameter or using 'Parent' . There are some calls that you cannot do this for, especially when it comes to things like bode plots, or trying to pre-create both axes for use with plotyy()
  1 Commento
Jennifer Davies
Jennifer Davies il 16 Nov 2017
Thanks Walter. I have just changed
axes(ax{2, 4})
to
set(gcf, 'CurrentAxes', ax{2, 4})
and this seems to work great. Thanks!

Accedi per commentare.

Categorie

Scopri di più su Specifying Target for Graphics Output in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by