Saving image in full screen with TiledLayout

32 visualizaciones (últimos 30 días)
Alessandro Maria Laspina
Alessandro Maria Laspina el 27 de Ag. de 2021
Editada: Dave B el 27 de Ag. de 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);

Respuestas (1)

Dave B
Dave B el 27 de Ag. de 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 comentario
Dave B
Dave B el 27 de Ag. de 2021
Editada: Dave B el 27 de Ag. de 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

Iniciar sesión para comentar.

Categorías

Más información sobre Data Exploration en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by