Saving image in full screen with TiledLayout
33 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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);
0 commentaires
Réponses (1)
Dave B
le 27 Août 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 commentaire
Dave B
le 27 Août 2021
Modifié(e) : Dave B
le 27 Août 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
Voir également
Catégories
En savoir plus sur Data Exploration dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!