Search code examples
matlabplotvisiblefigure

Save Matlab figure without plotting it and afterwards open it in VISIBLE state


I have the same question asked here: Save Matlab figure without plotting it?

But the problem with the solution given there is that I can't open the saved figures in visible state with doubleclick afterwards. Looks like the savefig command saves the visible state. Same with saveas.

h=figure;
set(h,'Visible','off');
savefig('TestExample.fig');

b=openfig('TestExample.fig');

With this command I can see the figure, but I simply want to doubleclick and see it:

set(b,'Visible','on');

Solution

  • The best solution for me is (thanks for links, How to edit property of figure saved in .fig file without displaying it):

    figure('Visible','off')
    set(gcf,'Visible','off','CreateFcn','set(gcf,''Visible'',''on'')')
    savefig('Test.fig')
    close
    

    Figures don't pop up and I can open them visible with doubleclick only.