make axes invisible or delete plot completely

前端 未结 4 656
既然无缘
既然无缘 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:41

    I now solved it with

    function z_removePlots(handles)
    
    if (isfield(handles,'image') && isfield(handles.image,'hplot'))
        if ishandle(handles.image.hplot)
            delete(handles.image.hplot);
            delete(findall(gcf,'tag','Colorbar'));
            handles.image.hplot = 0;
            set(handles.axesImage, 'Visible', 'off');
        end
    end
    if (isfield(handles,'contour') && isfield(handles.contour,'hplot'))
        if ishandle(handles.contour.hplot)
            delete(handles.contour.hplot);
            handles.contour.hplot = 0;
            ClearLinesFromAxes(handles.axesContour)
            set(handles.axesContour, 'Visible', 'off');
        end
    end
    guidata(handles.output,handles);
    

    with

    function ClearLinesFromAxes(axisObj)
    if ishandle(axisObj)
        handles2delete = get(axisObj,'Children');
        delete(handles2delete);
    end
    

提交回复
热议问题