How to overlay two previous saved, separate figure files

Hi. I have save two separate figures with x and Y data (scatter plots). I don't have the original set to re-run the analysis and use the "hold on" featured to overlay the separate plots. Is there anyway to then open the separate figures and overlay them as one figure?
Thanks in advance!

Answers (1)

I found a way around it, see code below:
% load saved figures
fig1 = hgload('/path');
fig2 = hgload('/path');
% Prepare 'subplot'
figure
h1=subplot(1,1,1);
h2=subplot(1,1,1);
copyobj(allchild(get(fig1,'CurrentAxes')),h1)
hold on
copyobj(allchild(get(fig2,'CurrentAxes')),h1)
Don't worry about the 'subplot' function. The eventual result is one plot, like so:

2 Comments

Thank you for the Answer, it workes for my problems, too.
I would like to change the colour of one line, but I don't know where I have to insert the command.
I can not change the properties in the former algorhithm of the figure because it ran as an standartised programm.
Du you have an ideas?
Thanks in advance!
If you open the original file of the figure you want to change the color of, you can use the property inspector to change the color of the line. Save it like that (or a copy if you prefer) and when you run this code it'll keep the color change.

Sign in to comment.

Categories

Asked:

on 1 Sep 2015

Commented:

Abi
on 30 Aug 2023

Community Treasure Hunt

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

Start Hunting!