For Live Editor: How to save figures in live editor in window state maximed or fullscreen?
14 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Sai Teja G
2023-11-22
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 个评论
Sai Teja G
2023-11-22
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Printing and Saving 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!