16
$\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$
17
$\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

$\endgroup$
  • $\begingroup$ Thanks! This is awesome. How do I extract the tabular data from the colormap? $\endgroup$ – Alex Jan 2 '18 at 6:18
  • $\begingroup$ @Alex, you mean InputForm/@ColorData["M10DefaultDensityGradient"] /@ Range[0, 1, .1]? $\endgroup$ – kglr Jan 2 '18 at 6:31
  • $\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$ – Alex Jan 2 '18 at 7:38
6
$\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$
5
$\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$
  • $\begingroup$ This is very useful to know! Thanks! $\endgroup$ – Alex Jan 2 '18 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$ – m_goldberg Jan 2 '18 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$ – Szabolcs Jan 2 '18 at 16:44
  • 1
    $\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$ – Ben Kalziqi Jan 2 '18 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$ – m_goldberg Jan 3 '18 at 2:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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