matlab crops figures when running with -nodesktop

11 ビュー (過去 30 日間)
Fabiano Baroni
Fabiano Baroni 2016 年 8 月 19 日
回答済み: Fabiano Baroni 2016 年 8 月 22 日
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.

回答 (2 件)

Fabiano Baroni
Fabiano Baroni 2016 年 8 月 19 日
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:

Fabiano Baroni
Fabiano Baroni 2016 年 8 月 22 日
I would like to add that the same problem happens when exporting to eps using export_fig. Since export_fig is the only tool that correctly exports figures to eps in matlab as far as I know (hgexport, print or saveas would not respect custom-set horizontal and vertical resolution even with the normal GUI running), this leaves me with little hopes of being able to generate figures with the desired resolution from within a -nodesktop job. Any help would be greatly appreciated.

カテゴリ

Help Center および File ExchangeThird-Party Cluster Configuration についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by