White regions in DensityPlot — is this a bug with ColorFunctionScaling?

9

Is this a bug with ColorFunctionScaling?

When I try to supply my own ColorFunction Mathematica seems to partially ignore it, and the white color "burns through" if the function is too "sharp":

mycf[z_] := RGBColor[z, 0, 0]

GraphicsRow[
  {DensityPlot[(Sin[x] Sin[y])^4, {x, 0, Pi}, {y, 0, Pi},
    ColorFunction -> mycf, ColorFunctionScaling -> False],
   DensityPlot[(Sin[x] Sin[y])^5, {x, 0, Pi}, {y, 0, Pi}, 
    ColorFunction -> mycf, ColorFunctionScaling -> False]}
]

density plots

Sampo Smolander

Posted 2012-11-08T01:05:30.033

Reputation: 290

A version of: (8390)

– Mr.Wizard – 2015-01-12T13:15:47.790

3Try PlotRange -> All. – J. M.'s ennui – 2012-11-08T01:09:21.140

Answers

21

DensityPlot[] was automatically cutting off your function at the peak. To fix this, add the option PlotRange -> All:

DensityPlot[(Sin[x] Sin[y])^5, {x, 0, Pi}, {y, 0, Pi}, 
            ColorFunction -> mycf, ColorFunctionScaling -> False, PlotRange -> All]

correct density plot


Why does Mathematica cut off values at all?

With the default setting of PlotRange -> Automatic, Mathematica will often choose not to show the highest or lowest values (outliers) in an attempt to present a useful plot. The decisions it makes are not perfect, but on average are better than a default of PlotRange -> All would be. Consider for example the following situation:

Mathematica graphics

J. M.'s ennui

Posted 2012-11-08T01:05:30.033

Reputation: 115 520

Why community wiki? – None – 2012-11-08T01:16:32.893

2@Rahul Because he can :) – Dr. belisarius – 2012-11-08T01:33:06.767