Keeping a history of plots previously generated by Live Editor code

조회 수: 17 (최근 30일)
z8080
z8080 2022년 4월 14일
답변: Pavan Sahith 2023년 10월 10일
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
z8080
z8080 2022년 5월 16일
It is very disappointing to see these forums reduced to such low traffic, and so little usability. If it's come so that any question takes weeks to get an answer, presumably because all the kind souls who used to help on here, have now migrated from Matlab to Python/JS/R, then perhaps that's what disappointed Matlab users are best advised to do as well.
YF Chong
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
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
Hope this helps you.

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

태그

제품


릴리스

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by