Getting handle for subplot of saved figure

54 ビュー (過去 30 日間)
Amol Khalate
Amol Khalate 2013 年 8 月 6 日
編集済み: dpb 2017 年 10 月 24 日
Dear all,
I've a saved Matlab figure, which has several subplots. I would like to know how to get handles for different subplots after opening this figure.

回答 (1 件)

dpb
dpb 2013 年 8 月 6 日
A) If you know the number of subplots/orientation a priori, then
h=subplot(n,m,i);
will return the handle for the existing subplot at that location when gcf is the correct figure.
B) To find them not knowing the above, after hgload()
h=get(gcf,'children');
as the axes are the children of the figure; other stuff is descended from the axes object. Can always check on the above to ensure that
get(get(gcf,'children'),'type')
returns axes
  7 件のコメント
Walter Roberson
Walter Roberson 2017 年 10 月 23 日
If you had tweaked the position of the subplots at all then subplot() is probably going to destroy rather than find what you want :(
... Probably the easiest way to handle all this is to assign distinct tags to each subplot when it is created, and then to later retrieve by tag.
dpb
dpb 2017 年 10 月 23 日
編集済み: dpb 2017 年 10 月 24 日
True, but that ship had sailed...at worst in OP's case if the figure had been munged on after creation all that's lost is a step of reading it again and using the other alternative of retrieving all handles. A nuisance, perhaps, but since he's starting with a saved figure already, nothing is going to be lost.

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by