How to plot graphs using secondary axis (plotyy does not zoom properly)



I am trying to plot a single graph which has:

- 3 traces against a primary y axis
- 2 traces against a secondary y axis

I have been using plotyy only to find that when I zoom into
the plot, only one of the traces will zoom.

The other traces stay fully zoomed out at 100% - this is
useless to me !

I need to be able to zoom into the graph and have all
traces zoom at the same time and at the same scale, all
relative to one another.

Theres also a problem when using the 'Data Cursor' tool to
mark data points - the tool will only work on one trace.

Am I doing something wrong or is this the limitation of
plotyy ?

For info, my code for plotyy is shown below:

[AX,H1,H2] = plotyy
(timetrace,InputSpeed,timetrace,ThrottlePedal,'plot');
%AX(1) is primary y axis
%AX(2) is secondary y axis
%H1 is plot against primary y axis
%H2 is plot against secondary y axis
set(H1,'Color','k')
set(H2,'Color','b')
set(get(AX(2),'Ylabel'),'String','Throttle Position (%) /
CSC Position (mm)')
hold;
%plot(timetrace,OutputSpeed,'m','LineWidth',2);
[BX,H3,H4] = plotyy
(timetrace,OutputSpeed,timetrace,CSCPosition,'plot');
%BX(1) is primary y axis
%BX(2) is secondary y axis
%H3 is plot against primary y axis
%H4 is plot against secondary y axis
set(H3,'Color','m')
set(H4,'Color',[0 0.5 0])
set(BX(2),'YColor','b')
set(get(AX(2),'Ylabel'),'String','CSC Position')
plot(timetrace,EngineSpeed,'r','LineWidth',2);
set(AX(1),'YColor','k')
set(AX(2),'YColor','k')
set(BX(1),'YColor','k')
set(BX(2),'YColor','k')

yscale=get(AX(2),'YLim');
set(BX(2),'YLim',yscale);
ytick=get(AX(2),'YTick');
set(BX(2),'YTick',ytick);

Another issue is that when I use plotyy for the second time
(to plot CSCPosition), the secondary y axis becomes
different to the secondary y plotted the first time
(ThrottlePedal).

This is why I have to make the YLim and YTick settings for
the first trace equal to that of the second trace.

But even then the y tick marks are wrong.

There must be an easier and better method of plotting
multiple traces on primary and secondary y axis?

Even excel can do better than this !
.



Relevant Pages

  • Re: How to plot graphs using secondary axis (plotyy does not zoom properly)
    ... - 3 traces against a primary y axis ... I have been using plotyy only to find that when I zoom ... powerful and better documented tool (called plt) available ...
    (comp.soft-sys.matlab)
  • Re: How to plot graphs using secondary axis (plotyy does not zoom properly)
    ... The issues you raise with PLOTYY have been addressed in R2008a. ... traces against a secondary y axis ... I have been using plotyy only to find that when I zoom into ...
    (comp.soft-sys.matlab)
  • Re: graph with multilpe axes
    ... i found that command plotyy but when I plot I can't ... easier than plotyy. ... A list of your workspace variables will appear. ... Then right click on the variable you want for the x axis, ...
    (comp.soft-sys.matlab)
  • Re: image to signal conversion
    ... seismic section there are large of traces side by sided ... i mean y axis represent timeand x ... shot refer to the number of traces" ... this mean each row pixel represent the sample per unit time and each ...
    (comp.soft-sys.matlab)
  • Re: labeling asecond axis
    ... I need to plot 2 one dimensional arrays, with one referencing the left Y ... the left Y axis and x axis label in the plot eeditor. ... The first output argument from PLOTYY is the handle to the two axes. ...
    (comp.soft-sys.matlab)