For Live Editor: How to save figures in live editor in window state maximed or fullscreen?
13 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, i am wondering can we save matlab figures using figure properties in live script.
F= figure;
F.WindowState="Maximized";
export_fig(F,"some name","-png");
The above code works perfectly in .mat format but not in .mlx format. In .mlx format, i have to manullay maximize the screen and than use the save command, otherwise it will just save the small figure created in live editor window.
Is there a workaround rather than converting the script to .mat format or am i missing something.
0 commentaires
Réponses (1)
Sai Teja G
le 22 Nov 2023
Hi Arjun,
I understand that you want to save the figures while working in Live Script Editor.
Several potential solutions exist to address this issue, and you may wish to experiment with both to determine which one effectively resolves your problem.
One method involves utilizing the 'maximize' function in conjunction with the 'pause' function to ensure that the figure fully renders within the Live Script Editor. Please refer to the following code as an example of how to implement this approach.
% Create a new figure
F = figure;
% Set the figure to not display inline in Live Script
set(F, 'WindowStyle', 'normal');
% Maximize the figure window
F.WindowState = 'maximized';
% Pause for a moment to ensure the window state is updated
pause(1);
% Export the figure using the 'export_fig' function
export_fig(F, 'some_name', '-png');
% Close the figure if not needed anymore
close(F);
Another method to save figures in MATLAB is by using the built-in functions 'exportgraphics' or 'saveas'. These functions allow you to save your figures programmatically with more control over the output format and appearance. Below is example of how to use these functions:
% Using 'saveas'
saveas(F, 'some_name.png');
% Or using 'exportgraphics' for better quality
exportgraphics(F, 'some_name.png');
Hope it helps!
3 commentaires
Sai Teja G
le 22 Nov 2023
Hi, both the workarounds are working fine for me. Can you tell me your exact workflow so that I can reproduce the error you are facing.
Voir également
Catégories
En savoir plus sur Printing and Saving 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!