しかし,プレゼン用画像の作成などでサイズを1024×768といった特別な値にしたい場合がしばしばあります.毎回やりかたを忘れて苦労するので,ここに方法をメモしておきます.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Figure を 1024x768 のPNG形式で | |
% "fig.png" に保存する例 | |
width = 1024; | |
height = 768; | |
set(gcf,'PaperPositionMode','auto') | |
pos=get(gcf,'Position'); | |
pos(3)=width-1; % なぜか幅が1px増えるので対処 | |
pos(4)=height; | |
set(gcf,'Position',pos); | |
print('-r0','-dpng','fig.png'); |
figure の PaperPositionMode を auto に設定し,print コマンドで '-r0' を付けるのがポイントのようです.ファイルを出力する際に幅が1ピクセル増える現象が発生しますが,バグなのか仕様なのか常に再現するのかもよく調べていません.バージョンによって挙動が異なる可能性もありますので注意してください.
3 件のコメント:
うまくいきました。
参考になりました。
ありがとうございます。
うまくできました。とても助かりました!
Thank you very much for seeing 밤알바 information.
Thank you very much for seeing 밤알바 information.
Thank you very much for seeing 밤알바 information.
Thank you very much for seeing 밤알바 information.
Thank you very much for seeing 밤알바 information.
コメントを投稿