Skip to main content

color - How to access new colour schemes in version 10?



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.



Answer



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


Comments