MATLAB Answers


How to combine two plots into one

Asked by SS
on 24 Aug 2019
Latest activity Commented on by Star Strider
on 26 Aug 2019
I am using MATLAB R2018 b. I have two plots with same x but, the limits of y axes are different. Both plots has a line and some data points (different color of the line and shape of the markers). These two plots are output from two different scripts. I want to combine these two plots to compare my results.
I am unable to use the dock figure option which was suggested for one such similar questions in the community.
Any help would be appreciated.


Sign in to comment.

1 Answer

Answer by Star Strider
on 24 Aug 2019
 Accepted Answer

Plot both data series on the same axes either in the same plot call, or use the hold function with two plot calls.


Add this line somewhere after the plot call loop:
set(gca, 'Box','on')
That will produce the full box outline. See the Axis Properties section on Box.
on 26 Aug 2019
As always, my pleasure.

Sign in to comment.