

How can I do this in Matlab I should also add that I am not interested in 'do-by-hand' solution. Thanks Jan, but how do you put those figures in subplots Replacing the first four lines with the two below just replaces the graphs in the new figure. Assign the Legend object to the variable lgd. I would like to merge them into one figure that contains both plots and with keeping the title of the figure and axis-labels (both figures have the same title and axis-labels). Assign the Axes objects to the variables ax1 and ax2.

The only input to the script is a txt file with 6 columns: x. The graphs I wish to combine i referred to as FIGURE 2 and FIGURE 4 in the below script.

I want to combine two of these graphs so that the are displayed simultaneously. Create two plots in two different figures. I am currently running a Matlab script (below) which produces four seperate graphs. Combine axes that exist in separate figures in a single figure with subplots.
Matlab combine figures into subplot full#
If we put all this together we can produce the full code as for i = 1:4 Convert Axes in Separate Figures to Subplots. To create a plot that spans multiple rows or columns, specify the span argument when you call nexttile. We can then we use copyobj() and allchild() to copy over each of the subplots to a new subplot in the new figure copyobj(allchild(h), s)Īllchild() copies over all of the information in barwitherr() that is left out from the code you've copied from a previous edit of my answer to your question. Once the figure we are interested in using figure(i) is the current gcf object we can get a handle to each of the subplot elements with s = subplot(2, 1, i) providing we know the structure of the subplots and i is the subplot we are interested in. You can loop through each of the original 4 figures and get handles for each of the subplots within it. Also, I want to take right graphs from every figure and combine them into one new figure. This may not be exactly what you want but is very extensible. I want to take left graphs from every figure and combine them into one new figure.
