Matlab: How to obtain all the axes handles in a figure handle?

前端 未结 4 1382
甜味超标
甜味超标 2020-12-04 22:06

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

Given the figure handle hf, I found that get(hf, \'children\') may return the hand

4条回答
  •  春和景丽
    2020-12-04 22:46

    Use FINDALL:

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

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

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

    EDIT

    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 will be true for every handle that is of type axes.

    EDIT2

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

提交回复
热议问题