Keeping a history of plots previously generated by Live Editor code
조회 수: 17 (최근 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에서 Graphics Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!