MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: DensityPlot colours misbehaving

  • To: mathgroup at smc.vnet.net
  • Subject: [mg78727] Re: [mg78705] DensityPlot colours misbehaving
  • From: Carl Woll <carlw at wolfram.com>
  • Date: Sun, 8 Jul 2007 06:03:48 -0400 (EDT)
  • References: <200707071005.GAA05698@smc.vnet.net>

Tim Birks wrote:

>I have Mathematica v6 and am running code that worked fine with v5. OS is 
>Windows XP. Here's a particularly annoying unexplained difference between 
>the two versions.
>
>DensityPlot[Exp[-x], {x, 0., 4.}, {y, 0., 4.}, ColorFunctionScaling -> 
>False]
>
>behaves as expected, giving a nice gradual horizontal grading of colour from 
>white on the left to blue/violet on the right.
>
>In contrast,
>
>DensityPlot[Exp[-x - y], {x, 0., 4.}, {y, 0., 4.}, ColorFunctionScaling -> 
>False]
>
>which should give a similar grading from lower-left to upper-right, instead 
>gives a mostly blue/violet field with a pure white triangular wedge in the 
>lower-left corner. The discontinuous jump between the two occurs roughly 
>where x+y=1.4.
>
>Re-plotting with x and y running from 0 to 2 instead of 4 makes the white 
>triangle appear smaller rather than bigger. Note the setting of 
>ColorFunctionScaling means that the colour at a particular point (x,y) 
>shouldn't depend on what's happening elsewhere; also note that the functions 
>plotted are very simple, well-behaved and evaluate to between 0 and 1 in the 
>ranges plotted.
>
>Can anyone please explain what is happening, how it can be fixed, and why it 
>is not a bug?
>
>Apologies if this has been asked before. I have searched the posts available 
>on my news reader and found nothing relevant.
>
>T.
>
>
>  
>
DensityPlot is not using the full PlotRange, as the highest value, 1, is 
several orders of magnitude larger than the smallest value Exp[-8] ~= 
.00034.

To correct this, use PlotRange->All:

DensityPlot[Exp[-x - y], {x, 0., 4.}, {y, 0., 4.},
 ColorFunctionScaling -> False, PlotRange -> All]

If you don't like the default color choice, you can use one of the 
ColorData gradients, e.g.:

DensityPlot[Exp[-x - y], {x, 0., 4.}, {y, 0., 4.},
 ColorFunction -> ColorData["Rainbow"], ColorFunctionScaling -> False,
  PlotRange -> All]

By the way, for this example, ColorFunctionScaling doesn't do anything, 
because (as you say) the range of values is already 0 to 1.

Carl Woll
Wolfram Research


  • Prev by Date: Re: MathKernel graphics call fails in ASP web service
  • Next by Date: SolveAlways documentation problem
  • Previous by thread: DensityPlot colours misbehaving
  • Next by thread: Re: DensityPlot colours misbehaving