MATLAB: Figure visibility changes upon axes call

axesaxisfiguregetproperty pairssetvisibility

Hi,
I have the following issue: I would like to create figures and keep them invisible. However when changing the current axis withhin my figures the visibility changes. Here is a small example showing what I mean:
f = figure('visible','off');
ax = axes;
set(ax,'Position',[0 0 1 1]);
axis manual
axis off
ax2 = axes;
plot(1:2,1:2);
axes(ax);
the last call to reset the current axes to the old axes object makes the whole figure become visible. I can reset this by resetting the visible property. But there will still be a short fraction of time, when the figure becomes visible, something I would like to avoid.
Anyone got an idea what could be causing this and how it could be avoided?

Best Answer

According to the axes help, the syntax axes(h) "makes existing axes h the current axes and brings the figure containing it into focus". I guess "into focus" includes being visible...
The help gives this example " to make an axes the current axes without changing the state of the parent figure", instead of
axes(axes_handle)
you should use
set(figure_handle,'CurrentAxes',axes_handle)
Related Question