7
$\begingroup$

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

$\endgroup$
  • 2
    $\begingroup$ Try PlotRange -> All. $\endgroup$ – J. M. is away Nov 8 '12 at 1:09
  • $\begingroup$ A version of: (8390) $\endgroup$ – Mr.Wizard Jan 12 '15 at 13:15
18
$\begingroup$

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

$\endgroup$
  • $\begingroup$ Why community wiki? $\endgroup$ – Rahul Nov 8 '12 at 1:16
  • 2
    $\begingroup$ @Rahul Because he can :) $\endgroup$ – Dr. belisarius Nov 8 '12 at 1:33

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.