Automatically remove white space from figure
Mostrar comentarios más antiguos
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 ?
Respuestas (5)
Image Analyst
el 3 de Dic. de 2020
6 votos
Try the new exportgraphics() function.
5 comentarios
Ajay Kumar
el 14 de Abr. de 2021
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
el 14 de Abr. de 2021
Editada: Image Analyst
el 14 de Abr. de 2021
I don't know. Call tech support and ask them.
Ritesh Chandra Tewari
el 15 de Jul. de 2021
It worked for me. Thanks!
Klas Lindgren
el 25 de Abr. de 2023
Life-saver! Thanks!
Julian Groß-Funk
el 7 de Mzo. de 2025
Pankaj
el 7 de Oct. de 2018
5 votos
Surender Raj
el 3 de Dic. de 2020
3 votos
This problem can be addressed manually in Export setup. Once figures are done File--> Export setup --> Size --> Check expand axes to fill figures.
2 comentarios
Tong Zhao
el 29 de Jul. de 2022
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
el 29 de Jul. de 2022
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
el 16 de Jul. de 2017
0 votos
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
el 11 de Jun. de 2021
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.
Categorías
Más información sobre Printing and Saving en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!