96

Mathematica 10 release appears to have changed the default styling of plots: the most visible changes are thicker lines and different default colors.

Thus, answers to this stackoverflow question are only valid for Mathematica < 10. For example, plots in this code will not give identical output in Mathematica 10, although they do in version 9:

fns = Table[x^n, {n, 0, 5}];
Plot[fns, {x, -1, 1}, PlotStyle -> ColorData[1, "ColorList"]]
Plot[fns, {x, -1, 1}]

enter image description here

So, my question is: what is the new way of getting the default colors to reproduce for own uses?

Ruslan
  • 7,152
  • 1
  • 23
  • 52

2 Answers2

145

The colors alone are indexed color scheme #97:

ColorData[97, "ColorList"]

enter image description here

Update: further digging in reveals these PlotTheme indexed color relationships:

{"Default"   -> 97,  "Earth"       -> 98,  "Garnet"      -> 99,  "Opal"       -> 100,
 "Sapphire"  -> 101, "Steel"       -> 102, "Sunrise"     -> 103, "Textbook"   -> 104,
 "Water"     -> 105, "BoldColor"   -> 106, "CoolColor"   -> 107, "DarkColor"  -> 108,
 "MarketingColor" -> 109, "NeonColor" -> 109, "PastelColor" -> 110, "RoyalColor" -> 111,
 "VibrantColor"   -> 112, "WarmColor" -> 113};

The colors are returned as plain RGBColor expressions; the colored squares are merely a formatting directive. You can still see the numeric data with:

ColorData[97, "ColorList"] // InputForm
{RGBColor[0.368417, 0.506779, 0.709798], . . .,
 RGBColor[0.28026441037696703, 0.715, 0.4292089322474965]}

You can get a somewhat nicer (rounded decimal) display using standard output by blocking the formatting rules for RGBColor using Defer:

Defer[RGBColor] @@@ ColorData[97, "ColorList"] // Column
RGBColor[0.368417, 0.506779, 0.709798]
. . .
RGBColor[0.280264, 0.715, 0.429209]

To get full styling information for the default and other Themes see:

For example:

Charting`ResolvePlotTheme[Automatic, Plot]

enter image description here

(Actually Automatic doesn't seem to be significant here as I get the same thing using 1 or Pi or "" in its place; apparently anything but another defined Theme.)

Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
  • 2
    To find the RGB values of the colors (instead of just displaying them), you can use ToString/@ ColorData[97, "ColorList"]. Then, to display these values next to the corresponding color, you can use Grid@Transpose@{ColorData[97,"ColorList"], ToString/@ColorData[97, "ColorList"]}. If anyone can find a better method to find the RGB values, I'd love to hear it. – seismatica Jul 12 '14 at 21:11
  • 2
    @seismatica See update. – Mr.Wizard Jul 12 '14 at 23:35
  • 2
    Fantastic, that this is so complicated ;) – Thomas Fankhauser Aug 12 '15 at 12:05
  • @Thomas If you like complicated be sure to read (87282) :^) – Mr.Wizard Aug 12 '15 at 13:48
  • @Mr.Wizard Do you know what the color scheme for Plot3D is? It seems that the first two colors from the default scheme (#97) for Plot are switched. Thanks! – AnInquiringMind Feb 18 '16 at 22:16
  • @PhysicsCodingEnthusiast No, but I'll try to find out. It does appear to be the first ten colors of #97 except with the first two reversed. – Mr.Wizard Feb 19 '16 at 05:49
  • 3
    @PhysicsCodingEnthusiast It comes from System`PlotThemeDump`$ThemeDefaultLighting which directly defines its colors from ColorData[97, "ColorList"][[{2, 1, 3, 4, 5, 6, 7, 8, 9, 10}]] so in this case it actually is exactly what it appears to be. – Mr.Wizard Feb 19 '16 at 06:07
  • @Mr.Wizard Thank you so much! It is quite strange, nonetheless, that the first two colors are switched. – AnInquiringMind Feb 22 '16 at 23:18
  • 1
    I should add that this thread discusses how to disable the color swatch formatting. – J. M.'s missing motivation May 26 '20 at 17:08
2

Try this

 fns = Table[x^n, {n, 0, 5}]; 
    Plot[fns, {x, -1, 1}, PlotTheme -> None] 
    Plot[fns, {x, -1, 1}, PlotTheme -> None]
Basheer Algohi
  • 19,917
  • 1
  • 31
  • 78
  • 4
    I seem to have read the question quite differently. I don't think Ruslan is asking how to reproduce the old defaults but rather how to access the directives underlying the new ones. – Mr.Wizard Jul 12 '14 at 06:35
  • Indeed, the old defaults are reproduced by first Plot in my example. – Ruslan Jul 12 '14 at 06:41
  • @Mr.Wizard, maybe you are right but I thought the way to get color manipulated as he want is to disable the new feature "Theme" so that it is not interfere with the way he used to change the color in V9. In all cases I think you are right that we need not to just disable this feature but rather understand it well so that we can work while the new feature is enabled. – Basheer Algohi Jul 12 '14 at 06:43