Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Control y-axes with plotyy

299 views
Skip to first unread message

Aaron Kaplan

unread,
Jul 8, 2009, 12:59:02 AM7/8/09
to
How do you control each axis' range using the 'plotyy' to plot two functions on the same plot.

I am plotting two simple sets of data, and I want to increase the y-axis range just so it looks nicer. For example, the first data set's values range from 100-110, but i'd like the axis to go from 90-120... and i'd like to do similarly for the second axis.

[AX,H1,H2] = plotyy(x,Ton,x,Period,'plot');
%
set(get(AX(1),'Ylabel'),'String','Time to \itClock On \rm[ns]')
set(get(AX(2),'Ylabel'),'String','Clock Period [ns]')
%
set(H1,'LineWidth',2)
set(H2,'LineWidth',2)
xlabel('Data Point')


I tried adjusting the third-to-last line to make it:
set(H2,'LineWidth',2,'YLim',[90 120])

but I get an error that says:
??? Error using ==> set
Bad value for line property: 'YLimInclude'.


And while I'm posting, could anyone elaborate on the difference between the set(get(AX(1)... line versus the set(H1,...) line. I don't fully understand the handle/gca business, what's the difference between calling AX(1) and H1 ? thanks!

Wayne King

unread,
Jul 8, 2009, 7:06:01 AM7/8/09
to
Hi Aaron, your problem is that 'ylim' is a property of the axis and not the line. For example,

x = 0:0.01:20;
y1 = 200*exp(-0.05*x).*sin(x);
y2 = 0.8*exp(-0.5*x).*sin(10*x);
[AX,H1,H2] = plotyy(x,y1,x,y2,'plot');

note if you enter

>>get(H2)

you will not get a 'ylim' property, but

>>get(AX(2))

you will. get() will show you what properties the handle has.

you can enter the following:

set(H2,'linewidth',2)
set(AX(2),'ylim',[-0.6 0.8])

Hope that helps,
wayne

"Aaron Kaplan" <aka...@gmail.com> wrote in message <h3192m$pgk$1...@fred.mathworks.com>...

0 new messages