       Re: Problem with ColorFunction in ListDensityPlot in

• To: mathgroup at smc.vnet.net
• Subject: [mg102847] Re: [mg102839] Problem with ColorFunction in ListDensityPlot in
• From: Patrick Scheibe <pscheibe at trm.uni-leipzig.de>
• Date: Sun, 30 Aug 2009 06:06:39 -0400 (EDT)
• References: <200908291030.GAA00291@smc.vnet.net>

```Hi,

compare the following outputs

Reap@ListDensityPlot[
Table[Sin[i + j^2], {i, 0, 3, 0.5}, {j, 0, 3, 0.5}],
ColorFunction -> ((Sow[{##}]; Hue[#]) &)];

and

Reap@ListPlot3D[Table[Sin[i + j^2], {i, 0, 3, 0.5}, {j, 0, 3, 0.5}],
ColorFunction -> ((Sow[{##}]; Hue[#]) &)]

you see, that the ListDensityPlot just doesn't get x,y and z values for
the ColorFunction. It only seems to receive the z values whereas the
ListPlot3D handles this differently.

So you have to write

ListDensityPlot[Table[Sin[i + j^2], {i, 0, 3, 0.05}, {j, 0, 3, 0.05}],
ColorFunction -> Function[{z}, Hue[z]]]

for Mathematica Version 7.
The strange thing is, that version 6 seems to handle this differently.
Compare in version 6 the output of

Reap@ListDensityPlot[
Table[Sin[i + j^2], {i, 0, 3, 0.5}, {j, 0, 3, 0.5}],
ColorFunction -> Function[{x, y, z}, Sow[{x, y, z}]; Hue[z]]]

and

Reap@ListDensityPlot[
Table[Sin[i + j^2], {i, 0, 3, 0.5}, {j, 0, 3, 0.5}],
ColorFunction -> ((Sow[{##}]; Hue[#]) &)]

It seems that when they see a Function[{x,y,z},..] they give *all*
parameters and when they see a pure function they only give the
z-values.

Can anyone resolve this?

Cheers
Patrick

On Sat, 2009-08-29 at 06:30 -0400, janey wrote:
> Has anyone tried using the ColorFunction option in ListDensityPlot? In
> version 6, the following works:
>
> ListDensityPlot[Table[Sin[i+j^2],{i,0,3,0.05},{j,
> 0,3,0.05}],ColorFunction=EF=82=AEFunction[{x,y,z},Hue[z]]]
>
> but not in version 7.
>
> It only seems to work now with the preprogrammed defaults, or pure
> functions.
>
> That example above is actually from the version 7 help page. It cannot
> even evaluate its own example
>
> (see under  examples/scope/presentation, 2nd one down) which, f
> evaluated, results in an empty plot.
> Is this a bug? Is there a way around this that anybody knows of?
>
> This problem exists in 7.0.0 and 7.1.0.
>
> Thanks,
> Janey.
>
>

```

• Prev by Date: Re: programatically creating and testing successive models
• Next by Date: Re: random variable
• Previous by thread: Problem with ColorFunction in ListDensityPlot in version 7
• Next by thread: Re: Problem with ColorFunction in ListDensityPlot in version 7