Combining Multiple Scatter plots into one figure

54 visualizaciones (últimos 30 días)
Saumey Jain
Saumey Jain el 24 de Mzo. de 2021
Respondida: Reshma Nerella el 5 de Abr. de 2021
I have scatter plots saved in multiple matlab figure files, generated using a GUI built in Matlab. I would like to overlay one over the other.
I amusing the following code to overlay say figure 1 onto figure 2:
fh1 = open('1.fig');
fh2= open('2.fig');
ax1 = get(fh1, 'Children');
ax2 = get(fh2, 'Children');
ax2p = get(ax2(1),'Children');
copyobj(ax2p, ax1(1));
I then export this figure as fig1_2 and then proceed to overlay fig 3 onto this combined figure using similar code. I always encounter the following issue:
Error using copyobj
Scatter cannot be a child of Legend.
Is there a solution to this other than manually exporting and plotting data?

Respuestas (1)

Reshma Nerella
Reshma Nerella el 5 de Abr. de 2021
Hi,
If you want to combine multiple scatter plots into a figure, you can try it out this way.
close all;
for i= 1:3
h(i) = openfig(num2str(i) + ".fig", 'invisible'); % opening figures named 1.fig, 2.fig and so on
end
f = figure;
for i = 1:3
plot(h(i).Children.Children.XData, h(i).Children.Children.YData); % overlay all the scatter plots on one figure
hold on;
end
title("Merged Scatter Plot");
hold off;
Hope this helps!

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by