No BSD License  

Highlights from
plots.m, plotses.m

4.0

4.0 | 6 ratings Rate this file 15 Downloads (last 30 days) File Size: 33.89 KB File ID: #10242
image thumbnail

plots.m, plotses.m

by Carlos Adrian Vargas Aguilera

 

06 Mar 2006 (Updated 13 Nov 2006)

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

| Watch this File

File Information
Description

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.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
plotyyy
This submission has inspired the following:
addaxes.m v1.1 (Sep 2009)

MATLAB release MATLAB 6.5 (R13)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (11)
09 Mar 2006 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!

18 Jan 2008 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
    

25 Feb 2008 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

26 Jun 2008 John M. Burton

It does exactly what I was looking for.

03 Jul 2008 Thierry Dalon

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

03 Jul 2008 Carlos Adrian Vargas Aguilera

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

Regards,

Carlos Vargas

24 Oct 2008 A Xu

How to set the range for each axis? Thanks

24 Oct 2008 Carlos Adrian Vargas Aguilera

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

31 Jul 2009 Carlos Adrian Vargas Aguilera

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

27 Aug 2009 Mario Liverpool

very good job, thank u!

13 Oct 2010 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

Please login to add a comment or rating.
Updates
13 Oct 2006

Some changes on the submit.

13 Nov 2006

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

Tag Activity for this File
Tag Applied By Date/Time
annotation Carlos Adrian Vargas Aguilera 22 Oct 2008 08:17:30
customization Carlos Adrian Vargas Aguilera 22 Oct 2008 08:17:30
plot Carlos Adrian Vargas Aguilera 22 Oct 2008 08:17:30
plotyy Carlos Adrian Vargas Aguilera 22 Oct 2008 08:17:30
plotxx Carlos Adrian Vargas Aguilera 22 Oct 2008 08:17:30
plotyyy Carlos Adrian Vargas Aguilera 22 Oct 2008 08:17:30
plotxxx Carlos Adrian Vargas Aguilera 22 Oct 2008 08:17:30
multiple axes Carlos Adrian Vargas Aguilera 22 Oct 2008 08:17:30
axes Carlos Adrian Vargas Aguilera 22 Oct 2008 08:17:30

Contact us at files@mathworks.com