Code covered by the BSD License  

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
plotSeries - Color-code multiple plots

5.0 | 2 ratings Rate this file 2 Downloads (last 30 days) File Size: 3.59 KB File ID: #33322 Version: 1.0
image thumbnail

plotSeries - Color-code multiple plots



plotSeries allows multiple plots to be easily color-coded

| Watch this File

File Information

[ PH CH colorList ] = plotSeries(AH,x,y,s,colormap,OPTIONS)
Plots x and y data with each column of y color-coded according to scalar values defined in s. plotSeries is particularly useful to illustrate how a x-y dataset *changes* in response to some value, s.
Colormap can be defined by a string or a four-column matrix. When a string is used or the argument is left empty, the colormap spans all values of s, linearly. When a four-column matrix is provided, the first column corresponds to potential values of s, the other three define the corresponding RGB values. The RGB values used for each column of y are interpolated from the rows of colormap, so there is no requirement for the number of rows of colormap to match up w/ the length of s.
If length(s) > 1, then a colorbar will be included as a legend for the line coloring.
Optional lineseries specifications (OPTIONS) will be applied to all plots.
plotSeries outputs a list of plotHandles (PH), a colorbar handle, (CH), and the colorList used for the plot. The colorList output can be used directly as the colormap argument for other calls to plotSeries, providing a mechanism to easily produce multiple plots using similar coloring schemes.
Example (cut and paste into the command-line):
% Show how sinc function changes as a function of s
s = 1:10;
x = (-1:1e-3:1).';
y = sinc(x*s);
figure; plotSeries(x,y,s,'jet','LineWidth',2);
AH - [1x1] [OPTIONAL] Axes handle
x - [NxS / Nx1] X-coordinate data
y - [NxS] Y-coordinate data
s - [1xS] Scalar value associated with each data series (length(s) = size(y,2))
colormap - [Cx4] Colormap to use for dataset coloring. Can be colormap string OR four-column colormap with 1st column corresponding to potential s values and 3 remaining columns corresponding to color. Note that the colormap will be interpolated to find the appropriate color for each dataset. ([] for 'default' colormap)
OPTIONS - Optional arguments for plot command

PH - [Sx1] Plot handle
CH - [1x1] Colorbar handle
colorScale - [Sx4] colormap w/ 1st column corresponding to s values and 3 remaining columns corresponding to color

N - Number of x-y coordinates to plot for each dataset
S - Number of datasets
C - Number of colors provided in colormap

MATLAB release MATLAB 7.7 (R2008b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
05 Aug 2012 Hoi Wong

Hoi Wong (view profile)

Great tool. I modified your function by adding drawnow() right before enabling colorbar() (at the bottom of the program) so that the plot won't get shrunk unjustifiably when I rescale the figure. Hope it'll be useful info to you.

22 Jun 2012 Andrew

Andrew (view profile)

Very useful. Good documentation and design. Thank you

Contact us