Code covered by the BSD License  

Highlights from
Colors for plotting

4.0 | 1 rating Rate this file 7 Downloads (last 30 days) File Size: 1.09 KB File ID: #43548 Version: 1.0
image thumbnail

Colors for plotting



Provides color variation for line plots.

| Watch this File

File Information

For multiple plots on the same figure, current color schemes are often not satisfactory. This function provides a smooth transition from red, through green, to blue. The function is especially suited for visualisation of the dependence of a variable over small variations of a parameter.

The following two ways can be used to reproduce the screenshot:

Color definition:
N = 50;
ColorSet = ColorBand(N);

Some data:
x = zeros(N, 2);
y = zeros(N, 2);
x(:,2) = N:-1:1;
y(:,2) = 1:N;

a) Separately set the color of each plot:
hold on
for m = 1:N
plot(x(m,:), y(m,:), 'color', ColorSet(m,:));

b) Manually set the color order:
hold all
set(gca, 'ColorOrder', ColorSet);
for m = 1:N
plot(x(m,:), y(m,:));

Special thanks to Jiro for the construction of a visually appealing example. See his blog on


Varycolor inspired this file.

Required Products MATLAB
MATLAB release MATLAB 7.14 (R2012a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (1)
08 Jul 2014 Benjamin

Benjamin (view profile)


Contact us