Size and resolution from an image saved as a graphic format file

1 回表示 (過去 30 日間)
Julián Francisco
Julián Francisco 2011 年 11 月 18 日
I have the following code to save a plot to a graphics format file. My problem is with the image obtained. If I save the image as a bmp image or as the others formats (for example, jpeg image), the appearance is different (resolution and size). I would like to know how I can fix this.
X = 0:pi/100:2*pi;
Y = sin(X);
fh = figure('toolbar','none','menubar','none');
Pan1 = uipanel(fh,'Units','normalized','Position',[0 0 0.5 1],'title',...
'Panel1');
Pan2 = uipanel(fh,'Units','normalized','Position',[0.5 0 0.5 1],'title',...
'Panel2');
haxes = axes('Parent',Pan2,'Units', 'normalized','Position',...
[0.125 0.1 0.75 0.75]);
hplot = plot(haxes,X,Y);
xlabel(haxes,'Time (second)');
ylabel(haxes,'Amplitude (meter)');
title(haxes,'Sine function');
FileName = uiputfile('*.bmp;*.png;*.jpg;*.tif','Save as');
ftmp = figure('Menu','none','Toolbar','none','Units','normalized',...
'Position',[-1000 -1000 1 1]);
new_axes = copyobj(haxes, ftmp);
set(new_axes,'Units','normalized','Position',[0.1 0.1 0.8 0.8]);
saveas(ftmp, FileName);
delete(ftmp);
delete(fh);

採用された回答

Walter Roberson
Walter Roberson 2011 年 11 月 18 日
If you use print() instead of saveas(), then you can use the -r option to set the resolution.
The contribution export_fig also supports setting resolution.
  1 件のコメント
Julián Francisco
Julián Francisco 2011 年 11 月 18 日
@Walter Roberson: Thank you so much for your answer.

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

その他の回答 (0 件)

カテゴリ

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