make axes invisible or delete plot completely

前端 未结 4 630
既然无缘
既然无缘 2021-01-19 05:24

I have a matlab gui that shall contain 4 plots. The first plot shall be updated if a different file is selected in a list. the other 3 shall only be visible (and be calculat

4条回答
  •  攒了一身酷
    2021-01-19 05:44

    You want to hide not only the axes, but all of their children:

    handles2hide = [handles.axesImage;cell2mat(get(handles.axesImage,'Children'))];
    set(handles2hide,'visible','off')
    

    The cell2mat is needed only if there are more than one handle stored in handles.axesImage

    Note that you'll need the full list of handles to make everything visible again.

    EDIT

    If you want to delete all axes (includes colorbars) and their children on a figure, you can do the following (if you have to exclude certain axes, you can use setdiff on the lists of handles):

    ah = findall(yourFigureHandle,'type','axes')
    if ~isempty(ah)
       delete(ah)
    end
    

提交回复
热议问题