Simple Question: I want to create beautiful density plots like those on a Wikipedia page:

enter image description here

Mathematica has a lot of built-in color functions but none of them is as good as Wikipedia's. I tried "Rainbow", "DarkRainbow", Hue, "TemperatureMap" and "ThermometerColors" so far.

I plot density plots of Zernike Polynomials with "Zernike.m" package. The code I use is as follows:

<< "Zernike.m"
  Zernike[i, Norm[{x, y}], ArcTan[x, y]], {x, y} \[Element] Disk[], 
  PlotRange -> All, ColorFunctionScaling -> False, PlotPoints -> 100, 
  Frame -> False, ColorFunction -> "TemperatureMap", 
  ColorFunctionScaling -> True], {i, 1, 10}]

And the result I'm not satisfied is as follows: TemperatureMap

How can I use a color function or create a color function like the one on the Wikipedia? Any advice is appreciated.

  • 3
    $\begingroup$ The color map you want is the jet color theme used by Matlab I think, and in my opinion it should be avoided if the goal is to convey information, see here for discussion. But you can define the color map using the code here: mathematica.stackexchange.com/a/64514/9490 $\endgroup$
    – Jason B.
    Commented Jul 6, 2018 at 11:11
  • 1
    $\begingroup$ Possible duplicate: mathematica.stackexchange.com/q/33511/9490 $\endgroup$
    – Jason B.
    Commented Jul 6, 2018 at 11:15
  • 1
    $\begingroup$ Why do you have ColorFunctionScaling -> False and ColorFunctionScaling -> True in your options? Part of the problem is that the default range for color functions is between 0 and 1; it looks like your polynomials have negative values in some regions (hence the solid blue) and values greater than +1 in others (the solid red regions.) $\endgroup$ Commented Jul 6, 2018 at 12:52

1 Answer 1


If the built-in color schemes here are not good for you, you can write your own.

See for example a scheme that I often use:

scheme = (Blend[{RGBColor[0.02, 1, 1], RGBColor[0, 0.48, 1], RGBColor[
 0, 0, 0.73], Black, RGBColor[0.6, 0.22, 0], RGBColor[1, 0.55, 0],
  White}, Rescale[#1, {-1, 1}]] &);

BarLegend[{scheme[#] &, {-1, 1}}]

enter image description here

You can change the colours of the scheme to obtain the combination you like the most.

See this question I asked some time ago for some useful details!


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