Re: How to plot graphs using secondary axis (plotyy does not zoom properly)
- From: "Dan Sternberg" <dsternbeNO@xxxxxxxxxxxxxxxxx>
- Date: Mon, 31 Mar 2008 16:28:03 -0400
Hi John,
The issues you raise with PLOTYY have been addressed in R2008a. For versions
of MATLAB prior, there is no clean work around for getting ZOOM to work
properly, though there are MATLAB Central File Exchange postings which may
be able to point you in the right direction.
-I hope this helps.
Dan
---
Dan Sternberg
The MathWorks, Inc.
"John Lintern" <john.lintern@xxxxxxxxxxxxx> wrote in message
news:fsquh2$nja$1@xxxxxxxxxxxxxxxxxxxxx
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 !
.
- References:
- How to plot graphs using secondary axis (plotyy does not zoom properly)
- From: John Lintern
- How to plot graphs using secondary axis (plotyy does not zoom properly)
- Prev by Date: General Questions on Simulink
- Next by Date: Requesting help on assigning weighting factors in Fgoalattain
- Previous by thread: Re: How to plot graphs using secondary axis (plotyy does not zoom properly)
- Next by thread: Tunable Parameters with S-function
- Index(es):
Relevant Pages
|