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

查看:49
本文介绍了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') 返回的句柄是否是 ax 句柄?

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?

谢谢!

推荐答案

使用 FINDALL:

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'));

isAxesaxes 类型的每个句柄都为真.

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

EDIT2

要仅选择不是图例的轴句柄,您需要清除轴列表(ax 句柄,方法是删除所有标签不是 'legend''颜色条':

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天全站免登陆