Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Displaying two plots with different yLim on the same axis

Subject: Displaying two plots with different yLim on the same axis

From: Yoav Rubin

Date: 26 Oct, 2007 05:30:02

Message: 1 of 3

Hi All,
I have two data sets that has the same x values, but differ
on their y values. Moreover, the y values are different by
several magnitudes. The problem is that I want to display
both of them on the same axis. If I just use plot and hold
on, the data set that has the smaller y values shrinks and
it is impossible to view it properly. Is there a way to plot
the second data set on the same axis (using hold on) but to
specify that the new plot needs a different y scale, that
would be presented on the other side of the axis?

thanks
Yoav

Subject: Displaying two plots with different yLim on the same axis

From: Daniel Sutoyo

Date: 26 Oct, 2007 05:40:03

Message: 2 of 3

Hello Yoav,

yup there is a way

plotty(x1,y1,x2,y2)

in your case, x1 = x2... and you'll have both plots on the
same figure with different y axis.

hope it helps

Daniel Sutoyo

"Yoav Rubin" <yoavrubin@hotmail.com> wrote in message
<ffru0q$q7o$1@fred.mathworks.com>...
> Hi All,
> I have two data sets that has the same x values, but differ
> on their y values. Moreover, the y values are different by
> several magnitudes. The problem is that I want to display
> both of them on the same axis. If I just use plot and hold
> on, the data set that has the smaller y values shrinks and
> it is impossible to view it properly. Is there a way to plot
> the second data set on the same axis (using hold on) but to
> specify that the new plot needs a different y scale, that
> would be presented on the other side of the axis?
>
> thanks
> Yoav

Subject: Displaying two plots with different yLim on the same axis

From: Paul Mennen

Date: 27 Oct, 2007 00:08:32

Message: 3 of 3

> Hello Yoav, yup there is a way
> plotty(x1,y1,x2,y2)
> Daniel Sutoyo

Actually Yoav, Daniel's suggestion won't work exactly
because he made a typographical error. He meant to
to suggest the function "plotyy" which will do what
you need.

Another choice is "plt", although it's not built in,
you have to get it from the file exchange. I like to
tout it as a better version of plotyy because of its
superior documentation, as well as for its superior
zooming, panning, and cursoring controls. But of course
you can be the judge of that :)

~Paul

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us