フィルターのクリア

Saving image in full screen with TiledLayout

26 ビュー (過去 30 日間)
Alessandro Maria Laspina
Alessandro Maria Laspina 2021 年 8 月 27 日
編集済み: Dave B 2021 年 8 月 27 日
With reference to this post: Saving a figure in full screen size? - MATLAB Answers - MATLAB Central (mathworks.com), I want to save a figure using the save function by forcing it to size it to my screen. This works with the post mentioned when using figure, but when using tiledLayout as:
t=tiledlayout(1,2,'Position',get(0,'Screensize'));
% plot goes here%
F = getframe(t);
saveas(F.data,'my_plot.jpg','jpg');
I get the following error:
Error using getframe (line 2)
A valid figure or axes handle must be specified
Error in plot_test (line
3)
F = getframe(t);

回答 (1 件)

Dave B
Dave B 2021 年 8 月 27 日
Could you set the figure position to be fullscreen, and keep the tiledlayout at the default (which occupies the full figure window)?
fig = figure('Position', get(0, 'Screensize'));
t=tiledlayout(1,2);
% plot goes here%
F = getframe(fig);
imwrite(F.cdata, 'my_plot.jpg', 'jpg')
  1 件のコメント
Dave B
Dave B 2021 年 8 月 27 日
編集済み: Dave B 2021 年 8 月 27 日
(note that if you set tiledlayout's 'Padding' property to 'none' there won't be a border between the layout and the figure)
figure
set(gcf,'Color',[.8 .8 .8])
t=tiledlayout(2,2);
for i = 1:4;nexttile;end
figure
set(gcf,'Color',[.8 .8 .8])
t=tiledlayout(2,2,'Padding','none');
for i = 1:4;nexttile;end

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

カテゴリ

Help Center および File ExchangeGraphics Object Properties についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by