Scale changes on plots when saving the figure

46 ビュー (過去 30 日間)
Peter
Peter 2014 年 7 月 31 日
コメント済み: Steven Hunsinger 2023 年 9 月 11 日
MATLAB Version: 8.2.0.701 (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';
set(hc,'PaperOrientation','portrait');
tmp = strfind(tmpname,' ');
tmpname(tmp) = '_'; clear tmp
saveas(hc, fullfile(jpg_path, [tmpname '.jpg']));
%print(hc, '-djpeg', fullfile(jpg_path, [tmpname '.jpg']));
  2 件のコメント
Steven Hunsinger
Steven Hunsinger 2023 年 9 月 11 日
I have the same issue, but the solution above doesn't fix it.
set(gcf, 'InvertHardcopy', 'off');
saveas(gcf, plotfile);
I've tried "exportgraphics" and some of the other solutions but I still get the wrong scale lables on the X axis on all plots on the right side of my tiled plots. Top is the Figure in MATLAB, bottom is the .png. One of the changes I tried:
set(gca,'XTick',Expected(s+1:e,2));
added an extra data point at the end causing 1 to 100 to compress. The plot and the .png matched! But it was still wrong...
>> Expected(s+1:e,2)
ans =
0.0010
0.0100
0.1000
1.0000
9.9999
24.6680
99.9990
Steven Hunsinger
Steven Hunsinger 2023 年 9 月 11 日
update:
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');

サインインしてコメントする。

採用された回答

Namita Vishnubhotla
Namita Vishnubhotla 2014 年 7 月 31 日
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.

その他の回答 (1 件)

Peter
Peter 2014 年 7 月 31 日
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.

カテゴリ

Help Center および File ExchangePrinting and Saving についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by