Export a plot with predefined margins
25 ビュー (過去 30 日間)
古いコメントを表示
I'm using the below command to export my plot into a jpeg file:
% h is the handle for the figure
% File_W is my jpeg file name
exportgraphics(h, File_W, 'Resolution', 600);
It works well except one issue. The system will automatically crop the figure to the smallest possible without losing any information. However, that's not what I want.
Is there a way I could add a predefined margin/gap, e.g., 20 pixels to the top, bottom, left and right?
Many thanks.
0 件のコメント
採用された回答
TADA
2021 年 8 月 28 日
編集済み: TADA
2021 年 8 月 28 日
print(h, File_W, format, '-r600');
for instance, if you want to export as .tif file:
print(h, File_W, '-dtiff', '-r600');
3 件のコメント
TADA
2021 年 8 月 29 日
There has to be a better solution, but as a workaround I guess you can save with exportgraphics and programatically load the image and pad its margins
exportgraphics(h, File_W, 'Resolution', 600);
im = imread(File_W);
im2 = padarray(im, [20, 20, 0], 255);
imwrite(im2, File_W);
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!