File Exchange

## plotxx.m

version 1.0 (2.04 KB) by

PLOTXX Create graphs with x axes on both top and bottom

3.76923
13 Ratings

Updated

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.

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.

Aline Benezath

### Aline Benezath (view profile)

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

giga

### giga (view profile)

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

Joffray Guillory

David Verrelli

### David Verrelli (view profile)

% 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')

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.

Simon Vassant

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

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);
with
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)

abdur rahman

very useful thanks

Leo B

set(ax(1),'Box','on','ActivePositionProperty','position')
to get the position right
set(ax(2),'YAxisLocation','right','Color','none', ...
'XGrid','off','YGrid','off','Box','off');

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.

James Housley

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

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.

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!

Sacit Cetiner

Thanks, saved me a lot of programming

Izru Garner

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

yang ying

useful programme

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..

Lina Chang

Very helpful for creating nomographs. Thanks.