27
$\begingroup$

For example, the colors used on this page: http://reference.wolfram.com/language/ref/ContourStyle.html

or here: https://www.wolfram.com/mathematica/new-in-10/plot-themes/default.html

or here: https://www.wolfram.com/mathematica/new-in-10/enhanced-visualization/new-default-styles.html

(Look at the density plots or contour plots.)

An example:

enter image description here

I searched online, but can't seem to find any documentation or discussion of it. I searched the color schemes (http://reference.wolfram.com/language/guide/ColorSchemes.html) as well, still can't identifity which one it is.

Thanks!

$\endgroup$

4 Answers 4

35
$\begingroup$
"DefaultColorFunction" /. (Method/. Charting`ResolvePlotTheme[Automatic, ContourPlot]) 

"M10DefaultDensityGradient"

ColorData["M10DefaultDensityGradient", "ColorFunction"] 

ColorDataFunction["M10DefaultDensityGradient", "ThemeGradients",{0,1}, Blend["M10DefaultDensityGradient", #1]&]

ColorData["M10DefaultDensityGradient", "Panel"] 

enter image description here

SwatchLegend["M10DefaultDensityGradient", Table["", 15], LegendMarkerSize -> 50, LegendLayout -> {"Row", 1}] 

enter image description here

cp0 = ContourPlot[Sin[x y], {x, 0, 3}, {y, 0, 3}] cp1 = ContourPlot[Sin[x y], {x, 0, 3}, {y, 0, 3}, ColorFunction -> "M10DefaultDensityGradient"] ; cp2 = ContourPlot[Sin[x y], {x, 0, 3}, {y, 0, 3}, ColorFunction -> (Blend["M10DefaultDensityGradient", #1]&)]; 

enter image description here

cp0 === cp1 === cp2 

True

Update: To get the blending arguments we can use the function DataPaclets`ColorData`GetBlendArgument:

DataPaclets`ColorData`GetBlendArgument["M10DefaultDensityGradient"] 

enter image description here

The functions Blend[bl, #] & and ColorData["M10DefaultDensityGradient"]@# produce the same colors:

And @@ (ColorData["M10DefaultDensityGradient"]@# == Blend[bl, #] & /@ RandomReal[1, 1000]) 

True

$\endgroup$
3
  • $\begingroup$ Thanks! This is awesome. How do I extract the tabular data from the colormap? $\endgroup$ Commented Jan 2, 2018 at 6:18
  • $\begingroup$ @Alex, you mean InputForm/@ColorData["M10DefaultDensityGradient"] /@ Range[0, 1, .1]? $\endgroup$ Commented Jan 2, 2018 at 6:31
  • 1
    $\begingroup$ Yes! I assume that by default the number of colors is 256 in a colormap? Anyway, I found in another response below that I can get the number of native colors by Range[Length@ColorData["M10DefaultDensityGradient", "ColorList"]], if I am correct. $\endgroup$ Commented Jan 2, 2018 at 7:38
14
$\begingroup$

ColorData[97] is the default color scheme. The answer is found in a few different answers throughout this site. For example, Discussion of PointLegend and Discussion of DefaultColor. More examples can be found be searching for ColorData[97]

Below is a sample code showing that ColorData[97] matches the default colors. Note that the color of the points, created with ColorData[97], is the same as the color or the lines, created with default colors.

Plot[{Sin[x], Cos[x], Tan[x]}, {x, 0, 1.3} , Epilog -> {PointSize[0.03], ColorData[97, 1], Point[{1, Sin[1]}], ColorData[97, 2], Point[{1, Cos[1]}], ColorData[97, 3], Point[{1, Tan[1]}] }] 

enter image description here

The following statement will provide the RGBColor values

FullForm@ColorData[97, #] & /@ Range[Length@ColorData[97, "ColorList"]] // TableForm 

Below are the results: enter image description here

$\endgroup$
1
  • $\begingroup$ Note to current readers: the default color scheme in v14.2 is now ColorData[116]. $\endgroup$ Commented Nov 14 at 19:46
7
$\begingroup$

kglr's answer identifies the undocumented color function used by Mathematica and is, therefore, the best answer to this question. However, should you find yourself in a situation* where you don't know internals well enough to extract that kind of information, you can always fake the unknown color function with pretty good fidelity. In your case, the following is a good approximation to the actual color function Mathematica uses.

cf[u_] := Blend[ {RGBColor[.11, .25, 0.467], RGBColor[.89, .58, .26], RGBColor[1., 0.95, 0.70]}, u] ContourPlot[Sin[x y], {x, 0, 3}, {y, 0, 3}, ColorFunction -> cf] 

plot

The colors used in the blend were picked of the default plot using the dropper tool found on the color picker. Like so

picking_a_color

The step-by-step process is

  1. Make a color setter with

    ColorSetter[RGBColor[1, 1, 1]] 
  2. Click on the color setter to bring up the color picker dialog as shown above.

  3. Click on the dropper tool at bottom left of the palette. You will get a drag-able magnifier.
  4. Drag the magnifier over to a area which shows the color you want and click.
  5. Click on the color picker's OK button. The color setter will now show the selected color.
  6. Make a copy of the color setter and convert it to input form which will give an RGBColor expression for the color.

[*] Which is certainly the situation for me.

$\endgroup$
6
  • $\begingroup$ This is very useful to know! Thanks! $\endgroup$ Commented Jan 2, 2018 at 6:19
  • 1
    $\begingroup$ @Szabolcs. I have a ColorMunki spectrophotometer for screen and printer color calibration. It's supporting software installs an additional tab into the color picker. $\endgroup$ Commented Jan 2, 2018 at 16:18
  • 1
    $\begingroup$ I just discovered that the OS X colour picker is designed to be extensible with additional tabs. There are several tools out there providing new colour picker interfaces. Thanks! $\endgroup$ Commented Jan 2, 2018 at 16:44
  • 2
    $\begingroup$ You can also do a slight bit of "cheating" by just slapping DominantColors in front of the ContourPlot (or its output)—this is a fine way to grab usable color objects (I'm not sure what they're called in WL!) for use in other code. $\endgroup$ Commented Jan 2, 2018 at 22:02
  • 1
    $\begingroup$ @BenKalziqi. Good point. It's certainly quicker, but one must be careful to select from and/or reorder the results to get the right blend. $\endgroup$ Commented Jan 3, 2018 at 2:23
2
$\begingroup$

The default color scheme has changed as of Version 14.2. The current default color data function is given by evaluating

ColorData["DefaultPlotColors"] 

which, looking at the output, is at color data index 116

ColorData[116] 

The previous (Version 10) color data function is still available at

ColorData["DefaultPlotColorsV10"] 

or

ColorData[97] 

I picked this up by carefully watching Stephen's 14.2 announcement stream.

$\endgroup$
1
  • 1
    $\begingroup$ Actually Stephen is slightly wrong. Luckily, Charting`ResolvePlotTheme[Automatic, Plot] still gives the correct styling (even though this Q&A is about the ColorFunction in DenstyPlot and ContourPlot and not the PlotStyle of Plot). Note that Plot[Evaluate@Table[Sin[x + k/5], {k, 20}], {x, 0, 2 Pi}] and Plot[Evaluate@Table[Sin[x + k/5], {k, 20}], {x, 0, 2 Pi}, PlotStyle -> Table[ColorData[116][k], {k, 20}]] are not identical! But they're close enough for "normal" use cases, :) $\endgroup$ Commented Jan 27 at 0:54

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.