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.

 채택된 답변

TADA
TADA 2021년 8월 28일
편집: TADA 2021년 8월 28일

1 개 추천

theres the old school print function, still works well
print(h, File_W, format, '-r600');
for instance, if you want to export as .tif file:
print(h, File_W, '-dtiff', '-r600');

댓글 수: 3

Leon
Leon 2021년 8월 29일
Many thanks for the solution.
I guess it will work for most of the situations. Unfortunately, the "print" function has some issues with my "fancy" map boxes. It does not show them properly. Thus, I'd still hope there could be a solution using exportgraphics.
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);
Leon
Leon 2021년 8월 29일
Many thanks!
I'll purchase the Imagine Processing toolbox and try it out later.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Printing and Saving에 대해 자세히 알아보기

제품

릴리스

R2021a

질문:

2021년 8월 28일

댓글:

2021년 8월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by