5.0

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

plotSeries - Color-code multiple plots

by James Hall

 

17 Oct 2011

plotSeries allows multiple plots to be easily color-coded

| Watch this File

File Information
Description

[ 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);
xlabel('x-values');ylabel('y-values');
 
Inputs:
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

Outputs:
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  
Everyone's Tags
axes, axis, color, colormap, plot, plotting
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
05 Aug 2012 Hoi Wong

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

Very useful. Good documentation and design. Thank you

Contact us