Plot resolution and size

Hello,
I need to save my plot - extended in one direction (width) and in 8K resolution. How can I do that? I have only this
But it is unreable. What should I do now?

3 件のコメント

Khaled Almunem
Khaled Almunem 2018 年 8 月 23 日
編集済み: dpb 2018 年 8 月 23 日
ImageDPI=500;
ImageSizeX=6;
ImageSizeY=4;
ImageFontSize=12;
FileLabel='plot';
FontName='Garamond';
AxisFontName='CMU Serif';
figure1 = figure(1);
axes1 = axes('FontSize',ImageFontSize,'FontName',AxisFontName);
xlim(axes1,[min(t_main) max(t_main)]);
ylim(axes1,[0 0.011]);
box(axes1,'on');
hold(axes1,'all');
h=plot(time,variable);
set(h, 'LineWidth',1)
set(gca,'FontName',AxisFontName,'FontSize',ImageFontSize)
title('title')
xlabel('Time [s]','fontsize',ImageFontSize)
ylabel('Variable','fontsize',ImageFontSize)
set(gcf,'PaperUnits','inches','PaperPosition',[0 0 ImageSizeX ImageSizeY])
print('-dpng', strcat(FileLabel, '.png') , strcat('-r',num2str(ImageDPI)))
Adam Cervenka
Adam Cervenka 2018 年 8 月 23 日
Do not work with subplot.
Claudio Iturra
Claudio Iturra 2018 年 8 月 26 日
編集済み: Claudio Iturra 2018 年 8 月 27 日
Hello, I had a similar problem some time ago, The solution for me was saving the figure in EPS format, and then with illustrator force the resolution that I needed.

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

回答 (2 件)

Robert U
Robert U 2018 年 8 月 27 日

2 投票

Hello Adam Cervenka,
since Matlab is saving figures according to "PaperPosition", "PaperPositionMode" and "resolution", these values have to be adjusted accordingly to produce figures with specific pixel-sizes:
close all;
clear
% create some random data
Data = rand(20,100);
% open figure and plot results into subfigures
fh = figure;
for ik = 1:size(Data,1)
sh(ik) = subplot(4,5,ik,'Parent',fh);
ph(ik) = plot(sh(ik),1:size(Data,2),Data(ik,:));
sh(ik).Title.String = sprintf('Longer Title No. %d',ik);
end
% set all units inside figure to normalized so that everything is scaling accordingly
set(findall(fh,'Units','pixels'),'Units','normalized');
% do not show figure on screen
set(fh, 'visible', 'off')
% set figure units to pixels & adjust figure size
fh.Units = 'pixels';
fh.OuterPosition = [0 0 7680 4320];
% define resolution figure to be saved in dpi
res = 420;
% recalculate figure size to be saved
set(fh,'PaperPositionMode','manual')
fh.PaperUnits = 'inches';
fh.PaperPosition = [0 0 7680 4320]/res;
% save figure
print(fh,'TestFigure','-dpng',sprintf('-r%d',res))
Kind regards,
Robert

1 件のコメント

Youran Li
Youran Li 2021 年 6 月 20 日
Hi This is very useful! I tried to make an animation by stacking all the figures. Matlab somehow made the pixel length and width slightly different though I use the same code to make the figures. Your method works out in forcing the pixel length and width. Thanks!

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

Pau Pons
Pau Pons 2019 年 10 月 26 日

0 投票

helo ain the studn i homnew hed matlebö. My neim is Kväss lif in Hailikinikii norewy. dis hier is die tasken:

カテゴリ

ヘルプ センター および File ExchangeGraphics Objects についてさらに検索

製品

リリース

R2018a

質問済み:

2018 年 8 月 23 日

コメント済み:

2021 年 6 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by