altmany / export_fig

A MATLAB toolbox for exporting publication quality figures
BSD 3-Clause "New" or "Revised" License
1.27k stars 365 forks source link

First example code not working #371

Closed foret37 closed 6 months ago

foret37 commented 1 year ago

I just installed the latest version of export_fig, and I am running the latest version of Matlab (R2022b, update 5). I ran the first example:

plot(cos(linspace(0, 7, 1000)));
set(gcf, 'Position', [100 100 150 150]);
saveas(gcf, 'test.png');
export_fig test2.png

And saveas produced a png of the figure, but export_fig produced a blank png file.

BUT, I found that if I reversed the order of the functions, saveas and export_fig, then both functions produced versions of the fig. My guess is that this problem is due to a change in Matlab, given that this example worked previously.

Update: I found that the inclusion of the figure handle in export_fig solved this problem.

plot(cos(linspace(0, 7, 1000)));
set(gcf, 'Position', [100 100 150 150]);
saveas(gcf, 'test.png');
export_fig gcf test2.png

Best, Mark

altmany commented 1 year ago

I am running an earlier version of R2022b with no problem. Try to add drawnow; pause(0.2); just before your call to export_fig - perhaps this will resolve the issue

altmany commented 6 months ago

No feedback after a year and the reported problem cannot be reproduced, so closing this issue.