I am using ListPlot to display from 5 to 12 lines of busy data. The individual time series in my data are not easy to distinguish visually, as may be evident below, because the colors are not sufficiently different.

enter image description here

I have been trying to use PlotStyle, ColorDataand related functions to get better colors. I would rather not have to specify a specific list of colors because the number of plot items varies from test to test. I created a toy plot to experiment with - the problem is illustrated by lines "F" and "G", which seem to be almost the same color. PlotStyle -> ColorData doesn't seem to work. Is there a simple way to do this?

ListPlot[Table[i*Range[0, 10], {i, 1, 5, 0.5}]
 , Frame -> True, Joined -> True, PlotRange -> All
 , PlotLegends -> SwatchLegend[Characters["ABCDEFGHIGKLMNOP"]]
 , PlotStyle -> ColorData["TemperatureMap"]  ]

enter image description here

It looks like

ListLinePlot[Table[data2*i, {i, k}], PlotStyle -> Thick, 
ColorFunction -> Function[{x1, x2}, ColorData[c1][x2]]] 

from another question may be the answer. I didn't see that before. I'll try it out. I don't think I really understand ColorData. Meanwhile, if anyone has generally enlightening comments, I would appreciate them.

  • $\begingroup$ F and G seem to have quite distinguishable colors. I believe B and F are much closer to each other to the extent that I can't distinguish them easily. $\endgroup$ Feb 23, 2014 at 17:58
  • $\begingroup$ @SjoerdC.deVries Your are right; they are almost identical. $\endgroup$ Feb 23, 2014 at 18:06
  • $\begingroup$ Pick a long list of colors you like, at least as long as the highest number of plots you want, and use PlotStyle -> colors. Extra colors will be unused. $\endgroup$
    – Michael E2
    Feb 23, 2014 at 18:11
  • 1
    $\begingroup$ phrogz.net/css/distinct-colors.html lets you generate random, perceptually distinct colors according to parameters you can control. If the main objective is 12 visually distinct colors, then it's more a question of graphic design, not Mathematica. If you have access to V10 (on RPi, say), the default plot colors are perceptually more distinct, but there are only 10 of them (as I recall). $\endgroup$
    – Michael E2
    Feb 23, 2014 at 19:52
  • 1
    $\begingroup$ Is there some reason why this doesn;t suffice? ListPlot[Table[i*Range[0, 10], {i, 1, 5, 0.5}], Frame -> True, Joined -> True, PlotRange -> All, PlotStyle -> ColorData[3, "ColorList"]] $\endgroup$ Feb 23, 2014 at 22:53

4 Answers 4


As mentioned by others, you should read up on ColorDataFunctions. For example, you could evenly space colors across a continuous color scheme, for an arbitrary number of lines, with:

d = Table[i*Range[0, 10], {i, 1, 5, 0.5}];
ListPlot[d, Frame -> True, Joined -> True, PlotRange -> All, 
 PlotLegends -> SwatchLegend[Characters["ABCDEFGHIGKLMNOP"]], 
 PlotStyle -> ColorData["Rainbow"] /@ (Range[0, Length@d]/Length@d)]

enter image description here

  • $\begingroup$ I tried everything but the right thing with ColorData. It turns out this was a easy problem. Thanks. $\endgroup$ Feb 23, 2014 at 19:48

The key is to use one of the indexed color sets. You can find them in the color schemes palette or generate them using ColorData[c]. The j-th color in scheme i can be obtained using ColorData[i][j].

To generate a set of colors for use in PlotStyle you can use


Most color schemes only have a finite set of colors to choose from, except scheme 1 and 63. Scheme 1 happens to be the default color scheme.

The following code shows the color schemes as colored spheres in RGB space.

       Sphere[{##}, 1/10]& @@ #}& /@ (ColorData[c]/@Range[50]/. GrayLevel[g_]->RGBColor[g, g, g]), 
       Lighting -> "Neutral", 
       PlotRange -> {{0, 1}, {0, 1}, {0, 1}}, PlotRangePadding -> 1/10, 
       PlotLabel -> c, ViewPoint -> {10, 5, 7}
    {c, 1, 93}
  6, 6, {1, 1}, {}] // GraphicsGrid

Mathematica graphics

You can choose a standard scheme or use your own colors, specifying the RGB values manually using RGBColor or Hue.

  • $\begingroup$ Woo Hoo! A thing of beauty. Thanks. $\endgroup$ Feb 23, 2014 at 19:42
  • $\begingroup$ This is a really nice way to look at these schemes $\endgroup$
    – mfvonh
    Feb 23, 2014 at 20:10
  • $\begingroup$ @mfvonh Perhaps a color conversion to CIELab space using ColorConvert would be even better. In that way it's easier to see whether the color scheme has a good, perceptually distinguishable set of colors. $\endgroup$ Feb 23, 2014 at 20:16
  • $\begingroup$ hmm... this makes me think that somebody must have put some thought into the design of these different numbered schemes. For example, scheme, say, 88, should be specifically valuable to illustrate... what exactly? $\endgroup$
    – Thomas
    Feb 23, 2014 at 23:14
  • $\begingroup$ @thomas They look better when shown in the designed linear order instead of in RGB space. The name (in the palette's tooltip) may give a hint about its intended use. $\endgroup$ Feb 24, 2014 at 7:05

I just use "ColorList"

ListPlot[Table[i*Range[0, 10], {i, 1, 5, 0.5}], Frame -> True, 
 Joined -> True, PlotRange -> All, 
 PlotStyle -> ColorData[3, "ColorList"]]

enter image description here

You can add some interactivity and choose between the 60+ colour data numbers until you find your preferred set.

From the docs:

enter image description here


In case all else fails :) ...

n = 8;
  Frame -> True,
  Joined -> True,
  PlotRange -> All,
  PlotLegends -> SwatchLegend[Characters["ABCDEFGHIGKLMNOP"]],
  PlotStyle -> cs],
 {{cs, Array[RGBColor[0.`, 0.`, 0.`] &, n]}, ControlType -> None},
 Column[Outer[Legended[ColorSlider[Dynamic[cs[[#1]]],  AppearanceElements -> "Swatch"], #1]&,
 Initialization -> (d = Table[i*Range[0, 10], {i, 1, n}]), 
 ControlPlacement -> Right]

Mathematica graphics


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.