Keeping a history of plots previously generated by Live Editor code

9 Ansichten (letzte 30 Tage)
z8080
z8080 am 14 Apr. 2022
Beantwortet: Pavan Sahith am 10 Okt. 2023
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 Kommentare
z8080
z8080 am 16 Mai 2022
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 am 19 Sep. 2023
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')

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Pavan Sahith
Pavan Sahith am 10 Okt. 2023
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.

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by