How can I keep figures invisible when toggling between axes?
2 views (last 30 days)
Show older comments
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
0 Comments
Answers (2)
Rik
on 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
on 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()
See Also
Categories
Find more on Combine Multiple Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!