As an update, I think that this problem is likely to be related to a known failure of matlab to take into account resolution settings when exporting to png and other formats while running with the -nodesktop option:
matlab crops figures when running with -nodesktop
1 次查看(过去 30 天)
显示 更早的评论
I'm using matlab R2014b from within a slurm job (with the -nodesktop option).
If I leave the default size and position for the figure and axis, the figure comes out fine, but if I set larger values for the figure position and axis then the figure will be cropped when created from within a slurm job (with -nodesktop), as in the attached.
The problem can be reproduced with this simple code:
mystyle = hgexport('factorystyle');
mystyle.Units='normalized'; % if I leave this to the default (inches) it does't make a difference
mystyle.FontMode='none';
mystyle.Resolution = 100;
fh=figure()
plot([0 1],[0 1]);
set(gcf,'Position',[1 25 1280 669]);
set(gcf,'PaperPosition',[-2.4167 2.0156 13.3333 6.9688]);
set(gca,'Position',[0.1300 0.1135 0.7750 0.8115]);
figure_name='min_example_settingPos';
hgexport(fh,[figure_name '.png'],mystyle,'Format','png');
fh=figure()
plot([0 1],[0 1]);
figure_name='min_example';
hgexport(fh,[figure_name '.png'],mystyle,'Format','png');
I tried to use export_fig instead of hgexport, but the problem persists.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/155861/image.png)
0 个评论
回答(2 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!