View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

Join the 15-year community celebration.

Play games and win prizes!

» Learn more

4.4 | 33 ratings Rate this file 146 Downloads (last 30 days) File Size: 2.15 KB File ID: #1017 Version: 1.0
image thumbnail



Denis Gilbert (view profile)


06 Nov 2001 (Updated )

PLOTYYY - Extends plotyy to include a third y-axis

| Watch this File

File Information

PLOTYYY builds upon plotyy to include a third y-axis. It also provides an easy way of labelling all three y-axes at once.


This file inspired Plotyn(Varargin), Plotyyyerrxy, Ploty4.M, Plots.M, Plotses.M, and Multiplotyyy.

MATLAB release MATLAB 6.1 (R12.1)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (42)
05 Oct 2016 Christian Hoey  
03 Oct 2016 liangsai liang  
22 Sep 2016 Kelley Sullivan

Hi. Great code! I'm having trouble with data-tips though. I can get data tips to appear on the 2nd and 3rd axes, but not the first. Any ideas? Thanks!

Comment only
25 Jul 2016 Sergio Machaca

Hey, when I run your example, I'm getting an error that says "Out of memory. The likely cause is an infinite recursion within the program." I would appreciate any help with this.

Comment only
07 Jul 2016 wenzhu wang

How to zoom in or zoom out the added line?

Comment only
27 Jun 2016 Wei Li

Wei Li (view profile)

Why my matlab can't implement this function? The warning says that "Error: Function definitions are not permitted in this context." Is it result from the lower version of matlab?

Comment only
26 Apr 2016 Marc Timmer  
03 Feb 2016 karthik aditya  
01 Feb 2016 Tino K.

Hey to everyone,

is it possible to have the third plot as a bar? I don't know how to solve the problem.

I would be pleased if somebody can give me an idea.

29 Jan 2016 Elizabeth

Hey, thanks for the code! It works well for me!

However, I can't make the visibility off for the figure. Anyone knows?

Comment only
23 Nov 2015 Olivia Yarney

Works well except when using view(-90 90) to rotate the plot it only rotates the first two and not the last plot?

16 Oct 2015 Thiago Seila  
15 Oct 2015 Andre

Andre (view profile)

anyone figure out how to use datetick for x axis with this function?

05 Oct 2015 Daniele Morello

Hi, if i would to use this function for "axes" of GUI instead of "figure"?

Comment only
27 Jan 2015 marc Oshe

Hello, thanks for the function plotyyy. I have a problem with x axis. It gives a far too wide area. How can I restrict the xlim such that I can have yearly axis? I tried to change the 'xlim' (set(ax,'xlim',[2001,2013]); ) but I just get error.

Comment only
05 May 2014 Brigh

Brigh (view profile)

25 Jan 2014 Jutao

Jutao (view profile)

22 Aug 2013 Oleg

Oleg (view profile)

23 Jun 2013 Ana C

Ana C (view profile)

14 Jun 2013 fitou

fitou (view profile)


I am using the function plotyyy and it works fine.
My problem occurs when change the 'xlim' (set(ax,'xlim',[1,12089]); )
The two first curve extend from the first Y axis to the second Y axis
wich is good because this area corresponds with path area. But the third
curve extends from the first Y Axis to the third Y axis wich is outside
of the path area.
As a result my third curve have a part outside of the path area..

Is anybody know how can I solve this ?

Comment only
09 Jun 2013 ww

ww (view profile)

Great function! However, I cant seem add an xaxis label. An example would be nice :)

23 Apr 2013 karthik

Zooming and data cursor problem .. .
only one layer is zooming . . .
what about other 2 layers . . .
plz help

Comment only
26 Feb 2013 Jakob Sievers

Jakob Sievers (view profile)

It appears my first comment failed to reach the page. Basically, if you want to use this in a subplot structure do:
- comment out "figure(..."
- pos=get(gca,'pos'); instead of pos = [0.1 0.1 0.7 0.8];
- pos(3)=pos(3)-offset; instead of pos(3)=pos(3)-offset/2;

26 Feb 2013 Jakob Sievers

Jakob Sievers (view profile)

26 Feb 2013 Jakob Sievers

Jakob Sievers (view profile)

correction to the second point:
I changed from
pos = [0.1 0.1 0.7 0.8];
is what I was trying to say.

13 Nov 2012 Stratos  
13 Mar 2012 qiong lin


First thanks for writing such a useful code. I have to add up to three axis and plotyyy works fine.

But the code only generates in new figure, and I didn't manage to generate the three axes into existing figure despite hard trying. Can you please show me how to solve the problem ?

To force the axes to generate in my existing figure, the code
'figure('units','normalized','DefaultAxesXMinorTick','on','DefaultAxesYminorTick','on')' in plotyyy.m is put in comment; plus, position unit converted in centimeter as is the case in my own figure.

The axis 1 and 2 show up, but not the third axis!!

Please any help would be really appreciated.

01 Aug 2011 Miguel Ignacio Barrios

good, thanks

24 Jul 2010 Wu Zhiyong

Thanks, very useful!

Can the third line be changed to be a bar plot?


27 Aug 2009 Mario Liverpool

Very well done! thank u! :)

13 May 2008 Karel Castro

Can't use it calling the file from path, but very useful, thanks! Also labels didn't works as is stated in the example.

25 Oct 2007 Hassan Ri

does not plot two x axes, but plotxx is listed as one of the keywords

22 Mar 2006 YI xu

cannot use in subplot, always generate in a new plot

02 Feb 2005 Izru Garner

Easy to use, and very practical!

09 Sep 2004 Anja Noser  
19 Dec 2003 Libor Wilda

looks realy good

13 Nov 2003 Bejoy Mathews

Thanks a lot..
But do you know any which can plot 5 axes at once?

22 Oct 2003 Si Betts  
05 Jun 2003 Chitra Parthiban

Thanks. It is very useful to plot and analysis the online data's together

16 Mar 2003 Lina Chang

Thanks for coming up with a way of adding additional axes.

05 Mar 2003 robs goldy

Very good

17 Feb 2003 Olivier G

small and simple but useful

Contact us