Closed AnselmDr closed 2 years ago
Are you using the latest export_fig version?
I downloaded the latest version and tried it again but sometimes it still happens.
Hey, I did a little more testing and it only seems to happen when doing subplots. All images with a single plot are fine. Did you have any success with the issue?
I found the cause: I used
set(groot, 'defaultFigureWindowState', 'maximized');
to maximize all figure windows created in my code. Unfortunately this causes the issue with the cut off Images. Another problem with setting a default value is, that it doesnt get cleared by clear all and the like. use
reset(groot)
at the beginning of the code if you want to be sure to have no problematic default settings making trouble.
The other options, minimized and fullscreen also mess up the images.
Instead use either
set(groot,'defaultfigureposition',[0 0 1920 1080])
or set the window size for each figure with for example
f1 = figure(1);
f1.Position = [0 0 1920 1080];
nice thing is, it works even when you disable that the figure windows are displayed
set(0, 'DefaultFigureVisible', 'off')
Edit:
Setting the figure at the size of the screen or larger causes issues. likely because position [0 0] is above the taskbar so a figure as large as the screen actually portrudes it at the top. so its better to set it at a smaller value. @altmany you might wanna look into this although I found a workaround for my issue.
I cannot reproduce the issue, even with maximized figures. I suspect that the underlying cause is that you're trying to export the figure before it is fully rendered by Matlab - graphics rendering happens in the background, so you might be calling export_fig before it has in fact completed.
One workaround is to add a call to drawnow
and possibly also a short pause (e.g. pause(0.5)
) after you create the figure and before you call export_fig.
Hm okay, well if someone else has this problem they maybe find my solution here. the workaround with pause and drawnow also didnt work for me.
Hello,
sometimes the exported figures are cut off somewhere in the picture horizontally.
example of cut off plot:
example of correct plot:
![correct plot](https://user-images.githubusercontent.com/89944907/149468168-9b63ef79-dd6a-4ef3-b30b-fab3cd8b70f5.png)
It doesnt produce an error message and the script keeps on being executed. The command is just in the simplest form:
export_fig(filename);
Executing the line again after the half image was exported fixes the file. The graphic is also nothing special, just a subplot with line plots. Are there any recomendations how to stop this problem?