Azzera filtri
Azzera filtri

Saving image in full screen with TiledLayout

22 visualizzazioni (ultimi 30 giorni)
Alessandro Maria Laspina
Alessandro Maria Laspina il 27 Ago 2021
Modificato: Dave B il 27 Ago 2021
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);

Risposte (1)

Dave B
Dave B il 27 Ago 2021
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 Commento
Dave B
Dave B il 27 Ago 2021
Modificato: Dave B il 27 Ago 2021
(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

Accedi per commentare.

Categorie

Scopri di più su Graphics Object Properties in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by