MATLAB Answers


How to combine two plots into one

Asked by SS
on 24 Aug 2019 at 12:55
Latest activity Edited by Tomer
on 31 Aug 2019 at 8:13
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 at 13:09
 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.


on 26 Aug 2019 at 7:34
Star Strider
on 26 Aug 2019 at 11:10
As always, my pleasure.
on 31 Aug 2019 at 6:06
I have used the above code to combine two matlab figs. and it gave this error
Index in position 1 exceeds array bounds (must not exceed 1).
Error in fish_plane_angle (line 14)
plot(X{k2}(1,:), Y{k2}(1,:),'p', X{k2}(2,:), Y{k2}(2,:),'-')

Sign in to comment.