Controlling ListPlot Line Colors

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

PlotStyle->ColorData[2]/@Range[8].

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.

Partition[
  Table[
    Graphics3D[{#, 
       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.


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


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

Tags:

Plotting