This should be quite simple, although I was not able to find a solution in the Matlab docs.
I have to plot two or more sets of data, that can be fit in two different ranges. So I can use plotyy to manage this.
What I want to do, is being able, once created a plot, to overwrite or simple add traces to one of the two axes, selectively. I tried to catch the parameters returned by plotyy, but I wasn’t able to decypher them.
Any help is appreciated.
The MATLAB documentation on
plotyystates thatreturns the handles of the two axes created in
haand the handles of the graphics objects from each plot inh1andh2.ha(1)is the left axes andha(2)is the right axes.So the first argument returned by
plotyyis a handle to each of the axes created. To plot on the left axis useplot(ha(1), x, y)and to plot on the right axis useplot(ha(2), x, y).If you don’t need the handles to the graphics objects plotted, you can just use
ha = plotyy(...). Otherwise,h1andh2returns the handles to the lines (or other graphics object) plotted in the call toplotyy. So, following the example in the documentation, setting the line styles of the two lines can be done like so: