how to save figures without margin?

72 views (last 30 days)
Jack Xiao
Jack Xiao on 11 May 2019
Commented: Nick Tsui on 17 Nov 2022
as the title, I need to save the figures or images shown in the figure with the same size of the image.
but there are always margins as shown in the following: (the size is 604x593)
the orginal image is : (the size is 500x430)
how to save figures without margin?

Accepted Answer

Valeriy on 23 Feb 2020
axis off; % If you have axis titles, labels, etc.
set (gca,'Position',[0 0 1 1]);
print(gcf,'Test.jpg', '-djpeg', '-r300');
Nick Tsui
Nick Tsui on 17 Nov 2022
There are still some margins on both left and right sides of the image.

Sign in to comment.

More Answers (0)


Find more on Convert Image Type in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by