96
$\begingroup$

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?

$\endgroup$
2
  • $\begingroup$ Thanks for the Accept. I added another method if you are interested in only the colors rather than full styling information. $\endgroup$
    – Mr.Wizard
    Jul 12, 2014 at 9:50
  • $\begingroup$ @Mr.Wizard thanks, this update is really helpful! $\endgroup$
    – Ruslan
    Jul 12, 2014 at 11:23

2 Answers 2

145
$\begingroup$

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.)

$\endgroup$
9
  • 2
    $\begingroup$ 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. $\endgroup$
    – seismatica
    Jul 12, 2014 at 21:11
  • 2
    $\begingroup$ @seismatica See update. $\endgroup$
    – Mr.Wizard
    Jul 12, 2014 at 23:35
  • 2
    $\begingroup$ Fantastic, that this is so complicated ;) $\endgroup$ Aug 12, 2015 at 12:05
  • 3
    $\begingroup$ @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. $\endgroup$
    – Mr.Wizard
    Feb 19, 2016 at 6:07
  • 1
    $\begingroup$ I should add that this thread discusses how to disable the color swatch formatting. $\endgroup$ May 26, 2020 at 17:08
2
$\begingroup$

Try this

 fns = Table[x^n, {n, 0, 5}]; 
    Plot[fns, {x, -1, 1}, PlotTheme -> None] 
    Plot[fns, {x, -1, 1}, PlotTheme -> None]
$\endgroup$
3
  • 4
    $\begingroup$ 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. $\endgroup$
    – Mr.Wizard
    Jul 12, 2014 at 6:35
  • $\begingroup$ Indeed, the old defaults are reproduced by first Plot in my example. $\endgroup$
    – Ruslan
    Jul 12, 2014 at 6:41
  • $\begingroup$ @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. $\endgroup$ Jul 12, 2014 at 6:43

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