Matlab:如何获取图形手柄中的所有轴手柄? [英] Matlab: How to obtain all the axes handles in a figure handle?

查看:190
本文介绍了Matlab:如何获取图形手柄中的所有轴手柄?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取图形手柄中的所有轴手柄?

How do I obtain all the axes handles in a figure handle?

鉴于图形手柄hf,我发现get(hf, 'children')可能返回所有轴的手柄.但是,《 Matlab帮助》建议它返回的不仅仅是轴柄:

Given the figure handle hf, I found that get(hf, 'children') may return the handles of all axes. However, the Matlab Help suggests that it may return more than just the axes handles:

该人物的孩子.一个包含所有轴的手柄的矢量,图中显示了用户界面对象.您可以更改手柄的顺序,从而更改显示器上对象的堆叠.

Children of the figure. A vector containing the handles of all axes, user-interface objects displayed within the figure. You can change the order of the handles and thereby change the stacking of the objects on the display.

有什么方法可以只获得图形手柄中的轴手柄吗?还是我怎么知道get(hf, 'children')返回的手柄是否是斧头手柄?

Is there any way to obtain only the axes handle in the figure handle? Or how do I know if the handle returned by get(hf, 'children') is an axe handle?

谢谢!

推荐答案

使用查找:

allAxesInFigure = findall(figureHandle,'type','axes');

如果要在Matlab中的任何位置获取所有轴手柄,则可以执行以下操作:

If you want to get all axes handles anywhere in Matlab, you could do the following:

allAxes = findall(0,'type','axes');

编辑

要回答问题的第二部分:您可以通过获取handles type属性来测试手柄列表是否为轴:

To answer the second part of your question: You can test for whether a list of handles are axes by getting the handles type property:

isAxes = strcmp('axes',get(listOfHandles,'type'));

isAxes对于类型为axes的每个句柄都是正确的.

isAxes will be true for every handle that is of type axes.

EDIT2

要仅选择非图例的轴手柄,您需要清除轴列表(ax手柄,方法是删除所有标记不是'legend''Colorbar'的手柄:

To select only axes handles that are not legends, you need to cleanup the list of axes (ax handles by removing all handles whose tag is not 'legend' or 'Colorbar':

axNoLegendsOrColorbars= ax(~ismember(get(ax,'Tag'),{'legend','Colobar'}))

这篇关于Matlab:如何获取图形手柄中的所有轴手柄?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆