MATLAB Answers

Iyk
0

subplot of already saved figures

Asked by Iyk
on 21 Aug 2013
Latest activity Commented on by Walter Roberson
on 28 Jan 2016 at 7:31

i have somany figures like dyke_tap, dyke_tbp,dyke_tcp and dyke_tdp...... they aare all bar plots and i want to have them side by side in other to compare them. i have seen ways of merging them, but that wont be good for what i want so i want to use a subplot. how can i use a subplot on already saved figures..... example ' having 'dyke_tap, dyke_tbp,dyke_tcp and dyke_tdp' side by side

  2 Comments

what is the images extension? .fig? .png?

Iyk
on 21 Aug 2013

.fig

Products

No products are associated with this question.

2 Answers

Answer by laurie
on 21 Aug 2013

Here is a small bit of code that does just that for two saved figures. The figures need to be saved in the .fig format with this code (hgload only takes .fig figures as inputs), but there might be some way to adapt this code to make it work for other formats.

% Load saved figures
c=hgload('MyFirstFigure.fig');
k=hgload('MySecondFigure.fig');
% Prepare subplots
figure
h(1)=subplot(1,2,1);
h(2)=subplot(1,2,2);
% Paste figures on the subplots
copyobj(allchild(get(c,'CurrentAxes')),h(1));
copyobj(allchild(get(k,'CurrentAxes')),h(2));
% Add legends
l(1)=legend(h(1),'LegendForFirstFigure')
l(2)=legend(h(2),'LegendForSecondFigure')

  4 Comments

Try

copyobj(allchild(c), h(1))
copyobj(allchild(k), h(2))
ismet saygu
on 28 Jan 2016 at 1:03

After you load saved figures (like c=hgload('MyFirstFigure.fig'); k=hgload('MySecondFigure.fig');), do not close the figure window

Walter Roberson
on 28 Jan 2016 at 7:31

You can close the figure windows once the copying is done.


Answer by Farhad Sedaghati on 22 Jun 2015
Edited by Farhad Sedaghati on 22 Jun 2015

You can use the following function to insert all the saved fig files next to each other: http://www.mathworks.com/matlabcentral/fileexchange/51236-subplot

  0 Comments


Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!