Code covered by the BSD License  

Highlights from
MULTIPLOT2 - Multiplot version for version prior to R2007a (do not use inputParser)

5.0

5.0 | 2 ratings Rate this file 8 Downloads (last 30 days) File Size: 3.15 KB File ID: #18178
image thumbnail

MULTIPLOT2 - Multiplot version for version prior to R2007a (do not use inputParser)

by Thomas Montagnon

 

02 Jan 2008 (Updated 22 Jul 2008)

2D-line plots on several axes with common x-axis

| Watch this File

File Information
Description

multiplot - 2D-line plots on several axes with common x-axis
multiplot(XDATA,YDATA,'PropertyName',PropertyValue,...) plots the data
stored in the cell arrays XDATA and YDATA in several subplots with a common
x-axis. multiplot also links all generated axes in order to synchronize the
zoom along the x-axis. See below for a description of each argument.

LINES = multiplot(XDATA,YDATA,'PropertyName',PropertyValue,...) performs the
actions as above and returns the handles of all the plotted lines in a cell
array which has the same length as XDATA.

[LINES,AXES] = multiplot(XDATA,YDATA,'PropertyName',PropertyValue,...)
performs the actions as the first syntax and returns the handles of all the
plotted lines in a cell array which has the same length as XDATA and all the
axes handles in a double array.

Required inputs and descriptions:
XData - Cell array. Contains the X data of the lines. Each cell
content is similar to to the X variable when you execute plot(X,Y).

YData - Cell array. Contains the Y data of the lines. Each cell
content is similar to to the Y variable when you execute plot(X,Y).
Note that YData must be the same length as XData.

Property/Value pairs and descriptions:

LineSpec - Cell array or char array. If LineSpec is a char array then it
specifies this line spec will be used for all lines. If LineSpec is a
cell array it must contain only char arrays and each cell will specify
the line spec of the corresponding cell in XData and YData.
Note that if LineSpec cell array has less elements than XData and YData
then line spec will be periodically reused.

XLabel - Char array. x-axis label displayed below the bottom axes.

YLabel - Cell array. Labels that will be displayed next to the y-axis
for each data.
Note that YLabel must be the same length as XData and YData.

Title - Char array. Label deisplayed on top of all axes.

XLim - Two elements double array. The lower and upper limits for the
common x-axis of all axes.

Example:
xdata = {1:20, linspace(-10,25,100), linspace(0,30,25)};
ydata = {2000 * rand(1,20) , rand(1,100) , 500 * rand(1,25)};
ylabel = {'1st Data','2nd Data','3rd Data'};
linespec = {'b-*','r:+','g'};
multiplot(xdata, ydata, 'YLabel', ylabel, ...
'LineSpec', linespec, 'Title', 'Graph Title', 'XLabel', 'time');

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
MULTIPLOT

MATLAB release MATLAB 7.5 (R2007b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
15 Jan 2008 M Imtiaz

Works fine for 3 traces but I get the following error when I try to plot more than 3 traces:
>> multiplot2({t t t t},{dy(:,1) dy(:,2) dy(:,3) dy(:,4)})
??? Error using ==> set
Invalid handle.

Error in ==> multiplot2 at 153
set(axesHdl(1:end-1),'XTickLabel',{});

27 Jun 2008 Jianhui Chen

Will be quite useful if it can work correctly when the number of subplots is more than 3--at this moment, I got the same error as M Imtiaz for 4 or more subplots:
??? Error using ==> set
Invalid handle.

Error in ==> multiplot2 at 153
set(axesHdl(1:3),'XTickLabel',{});

Please login to add a comment or rating.
Updates
22 Jul 2008

This file used to work with up to 3 axes.

I've update the function to work with up to N axes.

Tag Activity for this File
Tag Applied By Date/Time
data exploration Thomas Montagnon 22 Oct 2008 09:41:22
multiple plot Thomas Montagnon 22 Oct 2008 09:41:22
subplot Thomas Montagnon 22 Oct 2008 09:41:22
axes Thomas Montagnon 22 Oct 2008 09:41:22
y Thomas Montagnon 22 Oct 2008 09:41:22
plots Thomas Montagnon 22 Oct 2008 09:41:22
x Thomas Montagnon 22 Oct 2008 09:41:22
2d line Thomas Montagnon 22 Oct 2008 09:41:22
graphics Thomas Montagnon 22 Oct 2008 09:41:23

Contact us at files@mathworks.com