View License

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

» Watch video

Highlights from

3.8 | 13 ratings Rate this file 114 Downloads (last 30 days) File Size: 2.04 KB File ID: #317 Version: 1.0
image thumbnail



Denis Gilbert (view profile)


25 Jan 1999 (Updated )

PLOTXX Create graphs with x axes on both top and bottom

| Watch this File

File Information

PLOTXX Create graphs with x axes on both top and bottom
Similar to PLOTYY, but ... the independent variable is on the y-axis, and both dependent variables are on the x-axis.
For example, you may wish to plot temperature and salinity as a function of depth in the ocean. In the atmosphere, plot temperature and relative humidity as a function of altitude, etc.

MATLAB release MATLAB 5.2 (R10)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (19)
31 Jan 2016 Sam Lo

Sam Lo (view profile)

Try to do this with pcolor plot with one of the x-axis being an inverse of the other x-axis times some constant. Can't seem to get it to work.

Comment only
10 Dec 2013 Aline Benezath

Can someone help me??I´m trying to use this rotine with subplot, but I can´t do this and I saw another comments about this!Thank you

Comment only
15 Apr 2013 giga

giga (view profile)

very useful but sloppy code...
Could have done better...
Yet very useful

02 Aug 2011 Joffray Guillory

31 Mar 2010 David Verrelli

% This works at least:

set(findobj('Type','line'), 'LineWidth',lw)

% From web('jar:file:///C:/Program Files/MATLAB/R2009b/help/techdoc/help.jar!/ref/set.html', '-helpbrowser')

Comment only
25 Apr 2009 Jayne

Jayne (view profile)

Is it possible to make a bar graph and a line graph with different x axes on the same figure using this program? Thanks.

Comment only
07 Oct 2008 Simon Vassant

Good stuff. How can I make it work for inversely proportionnal axes : i.e. wavelength (in microns) and wavenumbers (in cm^-1) ?

Comment only
02 Oct 2008 Guyennon Nicolas

thanks a lot for this solution ! (very usefull for vertical profiles)

set(ax(1),'XLim',[min(x1) max(x1)]);
set(ax(2),'XLim',[min(x2) max(x2)]);

to get autoscale on both x axis

or you may prefer to use :
[low,high,ticks] = bestscale(ylim1(1),ylim1(2),ylim2(1),ylim2(2),islog1 | islog2);
set(ax(1),'XLim',[low(1) high(1)],'XTick',xticks1);
set(ax(2),'XLim',[low(2) high(2)],'XTick',xticks2);

if you want to get a better ticks layout

(see open plotyy to copy bestscale sub function)

04 May 2008 abdur rahman

very useful thanks

05 Dec 2007 Leo B

to get the position right
set(ax(2),'YAxisLocation','right','Color','none', ...

08 Nov 2006 Dave Sproson

To use with subplot, you need to comment out

set(ax(1),'Position',[0.12 0.12 0.75 0.70])

on line 65.

06 Nov 2006 James Housley

Is it just me, or does this not work with subplots?

24 Oct 2006 Peter Burns

To avoid inconsistent axes ranges, I suggest calling
> axis tight
after plotxx. You might consider adding this to the function as a precausion.

30 Nov 2005 Sloane Wiktorowicz

Useful as a corollary to plotyy. Would be useful to have two inversely proportional axes for one plot (e.g., wavelength on bottom and energy on top). Though this isn't too hard to do from plotxx. Thanks!

23 Oct 2005 Sacit Cetiner

Thanks, saved me a lot of programming

02 Feb 2005 Izru Garner

Well done Dennis by your scripts, I agree with Lina Chang.

21 Apr 2004 yang ying

useful programme

18 Jun 2003 Sachin Chandra

Very useful. I often why mathworks didnt have a function similar to plotyy..
I think additional parameters like passing colors,line width can be helpful too..

Comment only
16 Mar 2003 Lina Chang

Very helpful for creating nomographs. Thanks.


modifying description

02 Nov 2001

Two new input arguments have been added to ease the task of labeling the axes.

Contact us