Search code examples
imagematlabmatplotlibfigure

Open .fig file and delete some of the plot entries-Matlab


I have the following image stored as f7.fig. I want to open it again and delete all the other entries except the first (red), second (blue) and last(cyan). I want also to delete them from the legend. Is this possible?

enter image description here


Solution

  • An easy interactive approach would be like this:

    savefig(h, 'somefig.fig`); % Save figure
    % Close the figure ...
    openfig('somefig.fig'); % Open figure
    % Click on the curves you wanted to delete ....
    delete(gco); % delete object -> this takes care of the legend too
    % Click on the curves you wanted to delete ....
    delete(gco); 
    % so on...
    

    This approach here is also an alternative.