Clear Filters
Clear Filters

Already Saved Subplots to subplots including title and labels

4 views (last 30 days)
I am trying to reproduce already saved figures (.fig) to subplots in new figure I have tried the following code which I have found here . The code is works fine but it does not copy titles and labels, can someone suggest how it could be done
% Load saved figures
% Prepare subplots
% Paste figures on the subplots
% Add legends
Robenson's suggestion to try the following produces the error
copyobj(allchild(c), h(1))
copyobj(allchild(k), h(2))
Warning: This Menu cannot be copied. See what you can and cannot copy with COPYOBJ.

Answers (1)

Benjamin Kraus
Benjamin Kraus on 9 Nov 2017
Edited: Benjamin Kraus on 9 Nov 2017
Your first approach is copying all the axes children from one axes to another, which is not copying the axes itself (just its children), so it is not getting the title and labels (because those are properties on the axes).
Your second approach is trying to copy all the figure's children, which includes the toolbar and figure menus, so that is going a little overboard.
You could try copyobj on just the figure's children into a new figure.
f = figure;
ax1 = copyobj(c.Children, f);
ax2 = copyobj(k.Children, f);
Now you will likely need to set the position on the children in the new figure, so they don't overlap. Assuming each starting figure has a single axes, you can also add existing axes to a subplot like this:
subplot(1, 2, 1, ax1)
subplot(1, 2, 2, ax2)
If that doesn't work, we would need more details about your starting figures. Do they have legends or colorbars? How many axes are in each figure?
  1 Comment
Olumide Omotere
Olumide Omotere on 31 Jan 2020
I got the error there no current axes property on the figure class. I do i resolve this.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!