intercept of secondary axis

Hi,
Im plotting two lines using two axis. They are velocity and acceleration. My question is how can I make the 0 point on the two axis be at the same level? At the moment, the 0 on the secondary axis is inline with 50 on the primary axis.
plotyy(x,y1,x,y2,'plot');
Thank you

 Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 19 Jan. 2013
Bearbeitet: Azzi Abdelmalek am 19 Jan. 2013

0 Stimmen

After plotyy add this:
yt=get(gca, 'ytick');
yt(1)=[];
set(gca,'ytick',yt)

4 Kommentare

John
John am 19 Jan. 2013
Hi,
It gives an error:
Index of element to remove exceeds matrix dimensions.
Azzi Abdelmalek
Azzi Abdelmalek am 19 Jan. 2013
Bearbeitet: Azzi Abdelmalek am 19 Jan. 2013
I've edited the code, try again, if it don't work, post your code. And don't accept the answer before checking it
John
John am 19 Jan. 2013
Hi,
Noting happened, no error either.
My code is:
plotyy(x,y1,x,y2,'plot');
Azzi Abdelmalek
Azzi Abdelmalek am 19 Jan. 2013
please, post the code (allows copy past).

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Azzi Abdelmalek
Azzi Abdelmalek am 19 Jan. 2013
Bearbeitet: Azzi Abdelmalek am 19 Jan. 2013

0 Stimmen

Try this
close;
x=0:250;
y1=100*abs(sin(0.01*x)),
y2=10*cos(.04*x);
[ax,h1,h2]=plotyy(x,y1,x,y2,'plot');
yt=get(ax(1), 'ytick');
yt(1)=[];
set(ax(1),'ytick',yt)

5 Kommentare

John
John am 19 Jan. 2013
That didn't work either, one axis is 50 and same level of the other axis is 0.
Thanks
Azzi Abdelmalek
Azzi Abdelmalek am 19 Jan. 2013
What is the problem? the first axis or the second? Explain again clearly what do you want to get
Azzi Abdelmalek
Azzi Abdelmalek am 19 Jan. 2013
It will be helpful if you post your code
John
John am 19 Jan. 2013
All I have is 3 variables x, y1 and y2.
My code is: plotyy(x,y1,x,y2,'plot');
I'm trying to plot them on a graph with a secondary axis. But I need the the '0' point on both axis to be at the same level.
In the picture above, one axis is 50 and same level of the other axis is 0. I need the 0s inline.
Can this be done?
Thanks
Azzi Abdelmalek
Azzi Abdelmalek am 19 Jan. 2013
Bearbeitet: Azzi Abdelmalek am 19 Jan. 2013
Ok, I get it now, use
ylim=get(ax(1), 'ylim');
ytick=get(ax(1), 'ytick');
set(ax(2),'ylim',ylim,'ytick',ytick)
but you will loose the negative part

Melden Sie sich an, um zu kommentieren.

Kategorien

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by