View License

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

» Watch video

Highlights from

Join the 15-year community celebration.

Play games and win prizes!

» Learn more

4.6 | 16 ratings Rate this file 92 Downloads (last 30 days) File Size: 1.83 KB File ID: #21050 Version: 1.0
image thumbnail




12 Aug 2008 (Updated )

Provides maximum color variation for lines on plots.

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

| Watch this File

File Information

I was unhappy with the current implementation of the color schemes. This provides a way for a program to dynamicly scale the number of different colors on plots, and it ensures there won't be any color overlap.


This file inspired Linkage Solver, Add Legend Automatically Based On Tag Property Value, Cmapline, Generate Maximally Perceptually Distinct Colors, Colors For Plotting, and Varycolor Projector Friendly.

MATLAB release MATLAB 7.4 (R2007a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (22)
23 Aug 2016 Sam Horne  
30 Jul 2016 Hannes Mogensen

I have used this function A LOT! Very useful.

13 Feb 2015 Luke

Luke (view profile)

Goncalo, I am not sure if I fully understand what you are trying to do. This might be what you want.

dot_array = rand(10,44);
ColorSet = varycolor(10);
% each row gets its own color

for i = 1:10
x = 1:44; % need x values for plot
y = dot_array(i,:); %nab the ith row
h = plot(x,y);
hold all;
legend show Location NorthEastOutside

Comment only
12 Feb 2015 Gonçalo Figueira

does this applies to dot plots instead of lines?


dot_array = rand(10,44);
ColorSet = varycolor(44);

for i = 1:10

legend show Location NorthEastOutside
set(gca, 'ColorOrder', ColorSet);
hold all;

for ii = 1:44
plot(i,dot_array(i,ii); hold on

It's not working... Can anyone help me with this?

Comment only
02 Mar 2014 abc

abc (view profile)

It served my purpose completely. There is now a more sophisticated function inspired by this file, "Generate maximally perceptually-distinct colors".

10 Dec 2013 Felipe G. Nievinski

I found "Generate maximally perceptually-distinct colors" to be better in the case of a few lines.

07 Dec 2013 jeong woo


26 Sep 2013 Subhashree Mishra  
22 Jul 2013 Paula

Paula (view profile)

Very useful! Thanks a lot!

02 Apr 2013 Benjamin I

Benjamin I (view profile)


11 Feb 2013 Albert

Albert (view profile)

Very helpful!

04 Oct 2012 Shiguo

Shiguo (view profile)

10 Dec 2011 Nick Sinclair  
29 Sep 2011 Fabio Caponetti

Good and functional. Should be shipped as default configuration in the Matlab package.

13 Jun 2011 Kamil Wojcicki

Kamil Wojcicki (view profile)

28 Oct 2009 Khalil

Khalil (view profile)

19 May 2009 Daniel Helmick

Ryan, it sounds like you are going to be disappointed in this 'maximum' color separation too.

Open the file up, and you will see that this one is not 'maximum' for small numbers of line colors. Depending on how you quantify color separation, even large numbers of line colors could be argued to be non-maximum in some metrics.

I suspect CMAPLINE provides results more in line with your desires.

Comment only
29 Nov 2008 Ryan Ollos

Your function is nice. I have been trying to do something similar, in order to create a maximum number of distinct line colors to use as the axes ColorOrder. I haven't been able to figure out an algorithm which produces maximum color variation, and at the same time convince myself that the algorithm really gives the 'maximum' color variation.

So, my question is, how did you come up with the RGB curves, and if/how do you know that it is really optimal in terms of maximizing color variation?

Comment only
03 Oct 2008 Nikola Toljic


21 Aug 2008 Daniel Helmick

Yes, thank you. I saw those and wasn't happy. The pick of the week description does an excellent job of pointing out some of the utility with this file.

Comment only
15 Aug 2008 Matt S  
15 Aug 2008 Carlos Adrian Vargas Aguilera

Daniel, have you seen MATLAB's COLORMAP, JET, GRAY, LINES, etc?, or the functions at the FEx that lets you create a different colormap like USERCOLORMAP?

Comment only

Contact us