plotSeries - Color-code multiple plots

版本 1.0.0.0 (3.6 KB) 作者: James Hall
plotSeries allows multiple plots to be easily color-coded
410.0 次下载
更新时间 2011/10/17

查看许可证

[ 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

引用格式

James Hall (2025). plotSeries - Color-code multiple plots (https://ww2.mathworks.cn/matlabcentral/fileexchange/33322-plotseries-color-code-multiple-plots), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2008b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Color and Styling 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.0.0.0