How to change the plot proportions/size when exporting to jpg using live script in Matlab

11 ビュー (過去 30 日間)
Jacqui
Jacqui 2022 年 1 月 14 日
コメント済み: Jacqui 2022 年 1 月 14 日
Hi Everyone,
I try to automate exporting a plot from my live script to a jpg file.
when I export the plot no matter how (saveas, exportgraphics) the plot always reflects the image which is shown on the right side in the window(image 1).
The proportions change when I open the figure in separate window, change to full screen and save (see image 2). I would like to export that second variation with the code. The proportions and resolution look a lot better. Is there a way to create the jpg from the full screen window?
I was thinking one way could be to adjust all the font sizes. But I would prefer not to have to adjust all the font sizes of each label and each plot.
This is my code so far: (the commented lines were previous attempts)
%t = tiledlayout('flow','Padding','compact');
%t.Units = 'pixels';
%t.OuterPosition = [25 25 1920 911];
%nexttile;
figure
X = categorical({'South 000';'East 000';'West 000';'North 000';'South 001';'East 001';'West 001';'North 001';'South 003';'East 003';'West 003';'North 003';'South 01';'East 01';'West 01';'North 01';'South 02';'East 02';'West 02';'North 02'});
X = reordercats(X,{'South 000';'East 000';'West 000';'North 000';'South 001';'East 001';'West 001';'North 001';'South 003';'East 003';'West 003';'North 003';'South 01';'East 01';'West 01';'North 01';'South 02';'East 02';'West 02';'North 02'});
bar(X, q_w_n_daily, 'grouped');
%%Annotation
title('Winter Period, Daily Cumulative Heat-Losses out of the internal space','Simplified calculation process, %-Improvement based on South 02')
ylabel('Heatflux [kWh/m^2d]');
xlabel('Constructions');
text([1:length(X)], q_w_n_daily', num2str(percent_w_n','%0.2f'),'HorizontalAlignment','center','VerticalAlignment','bottom',"FontSize",8)
box off
%% export figure
f = gcf;
Result_Loc =['folder_location']
FileName = sprintf(['3.BarChart.HF_winter_neg' num2str(Climate) '.jpg'])
fullFileName = fullfile(Result_Loc, FileName);
exportgraphics(f, fullFileName,'Resolution',300)
%exportgraphics(t, fullFileName,'Resolution',300)
%exportgraphics(f,['BarChart.HF_winter_neg' num2str(Climate) '.jpg'],'Resolution',600)
%saveas(f, fullFileName);
I'm looking forward to get some input.
Thanks a lot!
Jacqui
  2 件のコメント
Ankit
Ankit 2022 年 1 月 14 日
I see you used saveas also, is it not giving you expected jpg file?
Jacqui
Jacqui 2022 年 1 月 14 日
No, It's the same as exportgraphics.

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

回答 (1 件)

Ankit
Ankit 2022 年 1 月 14 日
you can try this out. I hope this served your purpose.
set(gcf,'units','normalized','outerposition',[0 0 1 1]);
saveas(f, fullFileName);

カテゴリ

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

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by