How can i merge several subplot in one figure

23 views (last 30 days)
Hi every one
I have several subplots like :
and i want to merge them such as:
could anyone help me to do that?
Thank you so much.

Accepted Answer

Adam Danz
Adam Danz on 31 Oct 2020
Edited: Adam Danz on 19 Nov 2020
It looks like you might be using a stackedplot which currently doesn't support adding objects to the axes after the plot is created. You can, however, plot multiple lines in each axis (see this answer).
Subplots and tiledlayouts do allow adding objects to the axes.
Option 1:
  • use hold(ax,'on') to hold the axes 'ax'.
  • use plot(ax,____) to plot on axes 'ax'
Option 2:
  • Copy a plotted line 'h' to axes 'ax' using copyobj(h,ax)
  5 Comments
Niloufar Baba adam
Niloufar Baba adam on 2 Nov 2020
unfortunantly I'm not very good at programming, Thank you if you can help me
Adam Danz
Adam Danz on 2 Nov 2020
The phrase "it's not working" doesn't convey much information.
axHand.Title.String - should be a string that matches the axis title (assuming the axis has a title).
h.DisplayName = axHand.Title.String; - should assign the axis title as the line object's DisplayName (which will appear in the legend).
When you use the DisplayName property (which is a good idea), you don't need to re-define the legend strings when you call legend().
This line
legend(newAxes,'original response','the effects of H3,5', 'the effect of H3','the effect of H5')
should just be
legend(newAxes)

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!