Graphics Conversion Bug with DensityGraphics

• To: mathgroup at smc.vnet.net
• Subject: [mg52813] Graphics Conversion Bug with DensityGraphics
• From: "David Park" <djmp at earthlink.net>
• Date: Mon, 13 Dec 2004 04:24:02 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```There is a bug in the conversion routines from DensityGraphics to Graphics. The bug occurs when ColorFunctionScaling -> False is used.

Here is an example. Sample data:

f[x_, y_] := (x + y)(x - y);
data = Table[f[x, y], {x, -2, 2, 0.2}, {y, -2, 2, 0.2}];

A normal Desity graphics plot.

plot1 =
ListDensityPlot[data,
ColorFunction -> (Hue[(# + 4)/8] &),
ColorFunctionScaling -> False,
Mesh -> False,
MeshRange -> {{-2, 2}, {-2, 2}}]

We convert the above graphics to regular Graphics and extract the first part. It gives us a Raster function.

graphicsprim = First[Graphics[plot1]]

But the Raster function is incorrect because the option

ColorFunctionScaling -> False

has not been passed to Raster. If we Show the primitive graphics, they are incorrect.

Show[Graphics[{graphicsprim}],
AspectRatio -> Automatic,
Frame -> True]

If we reinsert the color function scaling option it then displays correctly.

Show[Graphics[{graphicsprim /.
Raster[args___] -> Raster[args, ColorFunctionScaling -> False]}],
AspectRatio -> Automatic,
Frame -> True]

Also notice that the same problem occurs if we try to combine this with other plots using DisplayTogether.

Needs["Graphics`Graphics`"]

plot2 = Show[Graphics[{Line[{{-2, -2}, {2, 2}}]}]]
DisplayTogether[plot1, plot2]

One might want to do this if one wanted a density plot to be a background to other graphics elements.

This is definitely a bug and one that should be easy to fix. All that is needed is to copy the ColorFunctionScaling option along with the ColorFunction option into the Raster command. ColorFunctionScaling is an option for Raster.

I submitted this bug report to WRI a week ago but received no reply other than the automated server reply. I'm wondering if it is necessary to purchase Premier service in order to submit bug reports?

David Park