Automatically remove white space from figure
이전 댓글 표시
How do I remove the white space from the figures ? I don't want to have to save the image then manually crop it.
Instead of Matlab's dumb figure it would be something like
smart_figure('NoWhiteSpace');
plot(..);
or
figure;
plot(..);
smart_clean('NoWhiteSpace');
Is there such a function ?
답변 (5개)
Image Analyst
2020년 12월 3일
6 개 추천
Try the new exportgraphics() function.
댓글 수: 5
Ajay Kumar
2021년 4월 14일
exportgraphics does not support to save all file types, for example, if I want to save a vector graphic (.svg) format, then what could be alternate solutions?
Image Analyst
2021년 4월 14일
편집: Image Analyst
2021년 4월 14일
I don't know. Call tech support and ask them.
Ritesh Chandra Tewari
2021년 7월 15일
It worked for me. Thanks!
Klas Lindgren
2023년 4월 25일
Life-saver! Thanks!
Julian Groß-Funk
2025년 3월 7일
Pankaj
2018년 10월 7일
5 개 추천
Surender Raj
2020년 12월 3일
3 개 추천
This problem can be addressed manually in Export setup. Once figures are done File--> Export setup --> Size --> Check expand axes to fill figures.
댓글 수: 2
Tong Zhao
2022년 7월 29일
Thank you, it worked, but I have an additional question: when the axes fills the figure, it breaks the aspect ratio of the content. How can I make sure that the aspect ratio stays the same when filling?
Image Analyst
2022년 7월 29일
What is in your axes? Line plots? Images? If it's images, use
axis('on', 'image');
to make sure the aspect ratio is correct.
Image Analyst
2017년 7월 16일
0 개 추천
Attach images showing what you have and what you want.
You can change the amount of gray padding about your axes by setting the Position property of the axes.
Julia
2021년 6월 11일
I find the following really useful:
First, assemble your figure as you normally would. Then, try this:
I0 = getframe;
imwrite(I0.cdata, fullfile(path,'image.png'))
I have the impression that it needs some time for saving, so if used in code where stuff happens after this line it can sometimes give weird results. If you have the figure ready and then execute the code from the command line, it normally works beautifully.
카테고리
도움말 센터 및 File Exchange에서 Printing and Saving에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!