Hide all elements of an axis

7 ビュー (過去 30 日間)
TastyPastry
TastyPastry 2015 年 10 月 20 日
回答済み: Robert 2015 年 10 月 21 日
I have two axes objects in a figure and I'd like to switch back and forth between them by hiding the appropriate object. There is a figure.plots(i) variable which stores the axes handles. When I try using
toHide = allchild(figure.plots(i));
set(toHide,'visible','off');
set(figure.plots(i),'visible','off');
the axis legend of the plot I'm trying to hide stays visible. Is there a way for me to switch the legend off without shifting focus of the axes using axes(h)? I'm trying to expand this to a GUI which can handle many axes and I know the axes(h) command can be slow.
  1 件のコメント
dpb
dpb 2015 年 10 月 20 日
編集済み: dpb 2015 年 10 月 21 日
No time to 'spearmint at the moment, but I suspect your problem is that the subject handle isn't being returned by allchild. Likely you could find it by use of findall
ADDENDUM What component, specifically, is meant by "the axis legend"? I was thinking above of a legend object...but not sure sure on rereading.
If not solved the problem as yet, as almost always the case, providing enough of a sample case that illustrates the problem so folks can reproduce the symptoms will help immeasurably instead of just trying to describe them.

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

採用された回答

Robert
Robert 2015 年 10 月 21 日
In MATLAB R2015a, Legends are children of the figure, not the axes. For example, I expect you will be able to find the legend with
get(gcf,'Children')
% or
findall(gcf,'Type','Legend')
If the situation permits, you would do better to save the legend object when you create the legend in the first place. Whatever you choose, you can hide it using the same set(h,'Visible','off') that you are using already.
In case it is helpful, it seems that findall returns the legends in order from newest to oldest (reverse the order they were created).

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLegend についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by