I am using plotyy to plot two vectors on different y-axes. I wish to add a third vector to one of the two axes. Can someone please tell me why the following code is not working?
[ax h1 h2] = plotyy(1:10,10*rand(1,10),1:10,rand(1,10));
hold on; plot(ax(2),1:10,rand(1,10));
??? Error using ==> plot
Parent destroyed during line creation
I simply wish to add an additional vector to one of the axes (ax(1),ax(2)) created by plotyy.
Apply
holdto the axis of interest.plotyyworks by creating two axes, one on top of the other. You are carefully adding the new vector to the second axis. Theholdproperty is also a per-axis property, so you just need to make sure that theholdis set on the same axis.