The following commands produce some very strange results -
plotyy(1:3,2:4,3:5,4:6)
hold on
plotyy(1:3,2.1:4.1,3:5,4.1:6.1)
I basically want to plot two different series on the left y axes and two more series on the right y axes. The above commands work fine for the left series, but produce weird results for the right one. The second green line doesn't look like it should.
The problem that you are having is related to the way that the plotyy
creates they plot. plotyy
creates two different axes that it plots on, and then mounts them into a single figure. When you issue the hold on
command, you are only freezing one of the axes. To fix this, you need to hold each one individually, and then plot back onto them using the plot
command.
[ax,hl,hr] = plotyy(1:3,2:4,3:5,4:6);
hold(ax(1), 'on')
hold(ax(2), 'on')
plot(ax(1), 1:3,2.1:4.1)
plot(ax(2), 3:5,4.1:6.1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With