File Exchange

## plots.m, plotses.m

version 1.0.0.0 (33.9 KB) by
Plots each column of a matriz vs a single axis. Improvement of plotyyy.

Updated 04 May 2016

Example:
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 '
'y=cos(x)'];
[hlines,haxes]=plots(x,Y,location,labels);

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.

### Cite As

Carlos Adrian Vargas Aguilera (2020). plots.m, plotses.m (https://www.mathworks.com/matlabcentral/fileexchange/10242-plots-m-plotses-m), MATLAB Central File Exchange. Retrieved .

liangsai liang

Florian Haase

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.

P K

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
[hlines,haxes]=plots(x,Y,location,labels);

Edward Steele

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

Mario Liverpool

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)];
end
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

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

Regards,

Carlos Vargas

Thierry Dalon

How do you handle zooming?

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!