File Exchange

image thumbnail

plots.m, plotses.m

Plots each column of a matriz vs a single axis. Improvement of plotyyy.


Updated 04 May 2016

View License

x = [-10:0.1:10]';
Y = [x x.^2 x.^3 cos(x)];
location = 'top';
labels = ['x-axis '
'y=x '
'y=x^2 '
'y=x^3 '

Plots the columns of the matrix Y versus the vector column x, using different axes at the top of the figure, with the specified axes-labels.

The location of the axes can be 'left' (default), 'right', 'top' or 'bottom'.

PLOTSES.M its the almost the same but with the axes moved from the fixed axis (useful?).

Both M-files come with the colored example of the screenshot.

Comments and Ratings (14)

I've displayed 4 datasets and the space between the axes is 20%. The problem now is that the curves are not overlaying each other. The forth curve starts 4*20% further left then the first curve.

So I can't check the data if there are special points within the curve which could belong together.


Thanks for the code, but I am getting the same error as Matt got:
Error in ==> plots at 62
set(gca,'Position',pos_fix); % New position

Error in ==> F_comparison at 94

A very versatile m-code: excellent! I was especially impressed that this code is able to be easily adapted to layer multiple x- or y- plots onto other types of figure (e.g. bar / barh) using your 'pos0' and 'pos_new' variables. Cheers! -ES

very good job, thank u!

To use 'reverse' in 'YDir' (or in 'XDIr' if 'left' o 'right' was used) in the included example use:

bt = 2; % 1=='bottom', 2=='top'
ylim = get(he,'YLim');
N = length(he);
for k = 1:N
d = ylim{1}(1,bt)-ylim{k}(1,bt);
ylim{k} = [ylim{1}(1,1)+d*(bt==2) ylim{1}(1,2)+d*(bt==1)];
set(he,{'YDir','YLim'},[repmat({'reverse'},N,1) ylim])

Cheers, the author

You just need to use >> set(he(1),'Xlim',[0 1]), to modify the limits of the first axes from 0 to 1. Carlos

A Xu

How to set the range for each axis? Thanks

Carlos Adrian Vargas Aguilera

To be honest, I dont't remember Thierry. Probably, it cannot handle zooming.


Carlos Vargas

Thierry Dalon

How do you handle zooming?
(linkaxes does not work properly)

John M. Burton

It does exactly what I was looking for.

Zach P

Mostly very good and clean. However, no easy way to set YDir to reverse. Will cause curves to not plot on comon axes

Matt Williams

I couldn't get it to work, except for the example. Kept getting the error:

??? Error using ==> set
Width and height must be > 0.

Error in ==> plots at 62
set(gca,'Position',pos_fix); % New position

Kathleen Edwards

A great and clean job. Finally I dont have the limitations of plotyyy, plotxx with the number of axes and their LOCATION! Thanks!


BSD License

English translation from spanish. Little changes on the submit and screenshot.

Some changes on the submit.

MATLAB Release Compatibility
Created with R13
Compatible with any release
Platform Compatibility
Windows macOS Linux