Figure visibility changes upon axes call

9 ビュー (過去 30 日間)
Thomas Pfau
Thomas Pfau 2014 年 9 月 18 日
編集済み: Stephen23 2014 年 9 月 18 日
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?
  1 件のコメント
Stephen23
Stephen23 2014 年 9 月 18 日
編集済み: Stephen23 2014 年 9 月 18 日
The behavior of figure, axes, plot, etc, is usually much more predictable if you use:
  • the optional handle input, and
  • specify the data and options using Property+Value pairs.
It takes a bit more writing (and learning), but it tends to remove most of these (perhaps unwanted) higher-level behaviors. For example in your code, simply replace
ax = axes;
set(ax,'Position',[0 0 1 1]);
with
ax = axes('Position',[0 0 1 1]);
Also note that plot creates its own axes, if need be.

サインインしてコメントする。

採用された回答

Stephen23
Stephen23 2014 年 9 月 18 日
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)
  1 件のコメント
Thomas Pfau
Thomas Pfau 2014 年 9 月 18 日
Aye, thats it. Stupid me should read the manual properly...
Thanks

サインインしてコメントする。

その他の回答 (1 件)

Adam
Adam 2014 年 9 月 18 日
axes(ax) brings the figure containing the axes into focus so I guess that includes making it visible too.
Why do you need to call
axes(ax)
though? I used to do that a lot, but now I tend to avoid ever doing it because I don't like having the focus changed in that way.
If you want to plot on a specific axes you can just use:
plot( ax, ... )

カテゴリ

Help Center および File ExchangeGraphics Object Properties についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by