How to plot graphs using secondary axis (plotyy does not zoom properly)
- From: "John Lintern" <john.lintern@xxxxxxxxxxxxx>
- Date: Mon, 31 Mar 2008 15:04:02 +0000 (UTC)
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 !
.
- Follow-Ups:
- Re: How to plot graphs using secondary axis (plotyy does not zoom properly)
- From: Dan Sternberg
- Re: How to plot graphs using secondary axis (plotyy does not zoom properly)
- From: Walter Roberson
- Re: How to plot graphs using secondary axis (plotyy does not zoom properly)
- Prev by Date: X-Windows Problem
- Next by Date: Re: plot
- Previous by thread: X-Windows Problem
- Next by thread: Re: How to plot graphs using secondary axis (plotyy does not zoom properly)
- Index(es):
Relevant Pages
|