Keeping a history of plots previously generated by Live Editor code
9 次查看(过去 30 天)
显示 更早的评论
When tweaking figures for publication, I change various parameters one at a time, and it is useful to compare the outputs (the plots) before & after, in each case, as well as across multiple parameters.
However, my LiveEditor output seems to replace the previous output at each run of a given code section, even if there is no clc or close all command in the code. Only outputs of other code sections remain. Thus, I need to export figures and compare them externally, which is cumbersome.
Is there any way to keep the 'history' of plots previously outputted by a given code section?
3 个评论
YF Chong
2023-9-19
This comment is not relevant to LiveEditor, but to any one who comes across this post in search of similar answers (like me), and who is working with an older version of Matlab (R2018b in my case).
An ugly hack that allows you to view just two versions of a plot at a time for the purpose of comparison would work as such, which saves time (compared to exporting your figures to an external image viewer program) if you're doing this comparison many times (e.g. within a for loop).
% Create your 1st figure
savefig('temp_fig.fig') % Save 1st figure
% Call 'paint' or similar to view your 1st figure
% Create your 2nd figure
% Call 'paint' or similar to view your 2nd figure
fig1_h = openfig('temp_fig.fig', 'visible'); % Display your 1st figure
% Use alt-tab here to swap between the two figures and compare them
close(fig1_h) % Close the 1st figure's viewer to prevent view windows from proliferating,
% useful especially if you're running this in a for loop
delete('temp_fig.fig')
回答(1 个)
Pavan Sahith
2023-10-10
Hi,
I understand you want to keep the history of previously generated plots.
To achieve that using ‘figure’ might help, it can be used to store the plots and by assigning the plotted output to a variable, you can access and compare the plots later.
For example:
% creates an empty figure (f1) initially
f1 = figure;
f2 = figure;
plot([1 2 3],[2 4 6]);
% in this way , f1 can be accessed later
figure(f1);
scatter((1:20),rand(1,20));
Please refer to this MathWorks documentation links to learn more about
Modify figures in Live Scripts -https://in.mathworks.com/help/matlab/matlab_prog/modify-output-figures.html
Hope this helps you.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!