How to overlap plots from different scripts?
Afficher commentaires plus anciens
Hello MATLAB community!
I am trying to overlap two plots from two different scripts in order to illustrate the different best fit lines for the two plots. I am a fairly new MATLAB learner and am unsure how to go about doing this. I tried combining the two scripts into one and following the first plot with "hold on," but that didn't work.
Any suggestions? Perhaps I could save my plot from the first script and upload it into the second script.
Thanks!
2 commentaires
Ameer Hamza
le 5 Oct 2020
My guess is that you are calling figure() in your second script, in which case hold on will not work as you are expecting.
Lucia Wagner
le 5 Oct 2020
Réponse acceptée
Plus de réponses (1)
Fangjun Jiang
le 5 Oct 2020
Modifié(e) : Fangjun Jiang
le 5 Oct 2020
In the first script or function, do f1=figure and then plot; return f1 if it is a function.
In the second script or function, do figure(f1);hold on and then plot;
If don't want to pass f1, you could add some unique name in the first figure. As long as you can find the figure in the first script, you can then do hold on and plot.
Below is in one script, but it could be split as long as figure f1 is not closed.
f1=figure;
plot(1:10);
f2=figure;
plot(rand(10));
figure(f1);
hold on;
plot(sin(1:0.1:5))
Catégories
En savoir plus sur Graphics Object Properties dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!