Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Many colour schemes and colour functions can be accessed using ColorData.

Version 10 introduced new default colour schemes, and a new customization option using PlotTheme. The colour themes accessible with PlotTheme have both discrete colour schemes and gradients.

Is there a standard way to access these? I.e. get a colour function that take a real argument in $[0,1]$ and returns a shade, or one that takes an integer argument and returns a colour, as with ColorData.

share|improve this question
4  
That's a good question. I know the new default colors are ColorData[97] with some slight variations between different plots. –  rcollyer Jul 10 at 19:15
    
The first two colours are occasionally exchanged, e.g. in Histogram. –  Szabolcs Jul 10 at 19:17
    
Right, and sometimes lightened/darkened depending on the general needs of the plot type. –  rcollyer Jul 10 at 19:19
add comment

1 Answer 1

Update 2: The content and organization of $PlotThemes in versions 10 and 9 are very different. In Version 10

 Charting`$PlotThemes

gives

enter image description here

whereas in Version 9, the content is organized around Charting/Plotting functions (See the picture in original post below.)

The color schemes can be obtained using:

 "Color"/. Charting`$PlotThemes
 (* BackgroundColor, BlackBackground, BoldColor, ClassicColor, CoolColor,
    DarkColor,GrayColor, NeonColor,PastelColor, RoyalColor, VibrantColor, WarmColor, 
    DefaultColor, EarthColor, GarnetColor, OpalColor, SapphireColor, SteelColor,
    SunriseColor, TextbookColor, WaterColor} *)

 Grid[{#,Row@(("DefaultPlotStyle"/.(Method/. 
   Charting`ResolvePlotTheme[#,   ListPlot]))/.
      Directive[x_,__]:>x)}&/@("Color"/. Charting`$PlotThemes),Dividers->All]

enter image description here

Update: The function that defines the color schemes and styles seems to be ResolvePlotTheme, which is in the Charting context in both Version 9 and 10.

?Charting`ResolvePlotTheme
(* too long  to copy here ... *)

For example,

Charting`ResolvePlotTheme["Vibrant", ContourPlot]
(* {BaseStyle -> GrayLevel[0.5], BoundaryStyle -> None, 
   ColorFunction -> (Blend[{Hue[0.5, 1, 0.5], Hue[0.35, 0.5, 0.7], 
                     Hue[0.17, 0.7, 0.9]}, #1] &), ContourStyle -> GrayLevel[1, 0.5],
   GridLines -> Automatic, 
   GridLinesStyle -> Directive[GrayLevel[0.5], Dashing[{0, Small}]], 
   Method -> {"GridLinesInFront" -> True}}  *)

So, one can access the color functions used in these themes using something like;

 Grid[{#, ColorFunction /. Charting`ResolvePlotTheme[#, ContourPlot]} & /@
          ("ContourPlot" /. Charting`$PlotThemes), Dividers -> All]

enter image description here

More generally, one can get the settings for ColorFunction, ChartStyle, PlotStyle BaseStyle etc. using a similar approach:

Grid[{#, Column@FilterRules[Charting`ResolvePlotTheme[#, PieChart], 
         {ColorFunction, ChartStyle, BaseStyle}]} & /@
  ("PieChart" /. Charting`$PlotThemes), Dividers -> All] 

enter image description here


PlotTheme seems to work in Version 9.0.1.0 as an undocumented feature:

?*`*PlotTheme*

enter image description here

After Unprotect and ClearAttributes[--,ReadProtected] one can access some details. For example:

?Charting`$PlotThemes

enter image description here

And, despite syntax hightlighting suggesting error, they work as expected:

Row[Plot[Table[BesselJ[n, x], {n, 5}], {x, 0, 10}, Evaluated -> True, 
ImageSize -> 400, PlotLabel -> Style[#, 20], 
Charting`PlotTheme -> #] & /@ {"Vibrant", "Monochrome"}]

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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