MATLAB: How to plot an existing MATLAB plots all in one figure using SUBPLOT

handle graphicsMATLABparentsubplot

I have four figures which are already plotted by another user, but I do not have the commands that he used to plot them. I am trying to plot them all in one figure using SUBPLOT command.

Best Answer

One way is to obtain the ‘XData’ and ‘YData’ of all the children of the figures then plot them again in one figure using the SUBPLOT command.
The following example shows how to obtain the ‘XData’ and ‘YData’:
plot(1:10) % for example this is your existing figure
ha1 = get(gca,'Children') %this returns the children of the axes
a1 = get(ha1,'Xdata') % obtain the XData
b1 = get(ha1,'Ydata') % obtain the YData
figure; % new figure
plot(a1,b1) %plot the data again
Similarly, obtain the XData and YData of all other figures then use SUBPLOT to plot them in one figure.