Scale changes on plots when saving the figure

77 views (last 30 days)
MATLAB Version: (R2013b)
I create a figure with 4 subplots. When I save the figure using the Figure Menu: File-Save, everything looks fine. If I use the saveas or the print functions, the Y axes change and the representation of the data is incorrect.
Menu Save (Correct):
saveas or print (Incorrect):
%%Save the Figure
jpg_path = '\\usdrdsech1na002\projects$\PUBLIC\PureWaveLinear\Build Info\AcousticMicroscope\TOF_Scans';
tmp = strfind(tmpname,' ');
tmpname(tmp) = '_'; clear tmp
saveas(hc, fullfile(jpg_path, [tmpname '.jpg']));
%print(hc, '-djpeg', fullfile(jpg_path, [tmpname '.jpg']));
Steven Hunsinger
Steven Hunsinger on 11 Sep 2023 at 15:47
f=figure('Position', [500, 200, 1050, 750],'Color','white');
plotdata=tiledlayout(3,2,'TileSpacing','tight', 'Padding','tight'); %hold on;
TileSpacing influence the outcome. With 'loose' we lose resolution on the axis ticks.
Changed figure code (larger scale) and it works:
f=figure('Position', [500, 200, 1120, 800],'Color','white');

Sign in to comment.

Accepted Answer

Namita Vishnubhotla
Namita Vishnubhotla on 31 Jul 2014
The following code resolves the figure resizing issue:
>> set(fig, 'PaperPositionMode', 'auto');
where 'fig' is your figure handle. You can also just pass 'gcf'.
The 'PaperPositionMode' property (as published in documentation) "ensures that the printed version is the same size as the onscreen version. With 'PaperPositionMode' set to 'auto' MATLAB does not resize the figure to fit the current value of the 'PaperPosition'."
Refer to the various properties listed in the figure properties and axes properties documentation for additional saving and printing settings that may affect the look of your figure when exporting to printer or file.

More Answers (1)

Peter on 31 Jul 2014
Thanks for the help. That fixed the problem. I still find it odd, that with the figure/jpg size aside, why the scales on the individual plots changed but the plotted data did not.


Find more on Printing and Saving 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!