Re: integrity of ListContourPlot, ListDensityPlot
- To: mathgroup at smc.vnet.net
- Subject: [mg23781] Re: integrity of ListContourPlot, ListDensityPlot
- From: Hartmut Wolf <hwolf at debis.com>
- Date: Sat, 10 Jun 2000 02:59:26 -0400 (EDT)
- Organization: debis Systemhaus
- References: <8hfe7o$hlf@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
my answer below
Paul Hoke schrieb:
>
> This question was raised after some help I received previously.
>
> It appears that ListContourPlot and ListDensityPlot can sometimes in
> appropriately display colors if there are a few extreme points in the
> data field.
>
> If the following notebook is run it works just fine:
>
> "Needs <<Graphics`Legend`"
> data = Table[
> 10.*Sin[x + y]Cos[x - y], {x, xmin = -Pi, xmax = Pi, Pi/24.},
> {y,
> ymin = -Pi, ymax = Pi, Pi/24.}];
> Plot3D[10Sin[x + y]Cos[x - y], {x, xmin, xmax}, {y, ymin, ymax},
> PlotPoints -> 25];
> ShowLegend[
> ListContourPlot[data, ColorFunction -> (Hue[1 - #/2] &), Contours ->
> 11,
> ContourLines -> False, DisplayFunction -> Identity], {Hue[1 - #/2]
> &,
> 11, ToString[Min[data]], ToString[Max[data]],
> LegendPosition -> {1.1, -.4}}];
> ShowLegend[
> ListDensityPlot[data, ColorFunction -> (Hue[1 - #/2] &), Mesh ->
> False,
> DisplayFunction -> Identity], {Hue[1 - #/2] &, 11,
> ToString[Max[data]],
> ToString[Min[data]], LegendPosition -> {1.1, -.4}}];
>
> However, if the first data point is changed to -90 and then the entire
> re-plot the data, the all of the values appear to be represented
> incorrectly in the legend. The minimum on the legend will be reported
> as -90 and all of the regions between -8 to -10 will appear as -60 when
> shaded if it is assumed that the legend applies a linear scale between
> the minimum and maximum
> Insert the following into the above notebook (the matrixform is just to
> inspect the data to just to see the raw data table)
> data[[1,1]]=-50
> MatrixForm[data]
>
> "Needs <<Graphics`Legend`"
> data = Table[
> 10.*Sin[x + y]Cos[x - y], {x, xmin = -Pi, xmax = Pi, Pi/24.},
> {y,
> ymin = -Pi, ymax = Pi, Pi/24.}];
> data[[1, 1]] = -90 ;
> MatrixForm[data]
> Plot3D[10Sin[x + y]Cos[x - y], {x, xmin, xmax}, {y, ymin, ymax},
> PlotPoints -> 25];
> ShowLegend[
> ListContourPlot[data, ColorFunction -> (Hue[1 - #/2] &), Contours ->
> 11,
> ContourLines -> False, DisplayFunction -> Identity], {Hue[1 - #/2]
> &,
> 11, ToString[Min[data]], ToString[Max[data]],
> LegendPosition -> {1.1, -.4}}];
> ShowLegend[
> ListDensityPlot[data, ColorFunction -> (Hue[1 - #/2] &), Mesh ->
> False,
> DisplayFunction -> Identity], {Hue[1 - #/2] &, 11,
> ToString[Max[data]],
> ToString[Min[data]], LegendPosition -> {1.1, -.4}}];
>
> if anybody has any input regarding this phenomena, I would greatly
> appreciate it.
>
Dear Paul,
that behaviour might appear as a riddle, yet finer observation will
resolve it!
First I'd like tho call you fixed data differently:
data = Table[10.*Sin[x + y]Cos[x - y],
{x, xmin = -Pi, xmax = Pi, Pi/24.},
{y, ymin = -Pi, ymax = Pi, Pi/24.}];
cdata = ReplacePart[data, -90, {1, 1}];
Then _look_ at you data with all means you have! ok, you took MatrixForm[cdata],
but also make a
ListPlot3D[cdata, Mesh -> False, ViewPoint -> {-0.7, -1.7, 1.}];
You already might have seen something! Look at the axes, z-Axis only goes
from -20. to +10. !!!!!
Now take your Density Plot:
ShowLegend[
ldp = ListDensityPlot[cdata, ColorFunction -> (Hue[1 - #/2] &),
Mesh -> False, DisplayFunction -> Identity], {Hue[1 - #/2] &, 11,
"don't", "know", LegendPosition -> {1.1, -.4}}];
and then look at
FullOptions[ldp, PlotRange]
{{-0.98, 49.98}, {-0.98, 49.98}, {-20., 10.}}
!!!!! Now,
(1) the scaling of the color function is done according to PlotRange ({-20,10.} here)
(2) values outside the bounds are clipped to the bound (see Help for Raster)
So you have two choices:
(1) Force your Plot to have the PlotRange you want:
ShowLegend[
ListDensityPlot[cdata, ColorFunction -> (Hue[1 - #/2] &), Mesh -> False,
DisplayFunction -> Identity, PlotRange -> {-90, 10}], {Hue[1 - #/2] &,
11, ToString[Min[data]], ToString[Max[data]],
LegendPosition -> {1.1, -.4}}];
(2) Adapt your Legend to real color function behaviour:
Module[{ldp, low, high},
ShowLegend[
ldp = ListDensityPlot[cdata, ColorFunction -> (Hue[1 - #/2] &),
Mesh -> False, DisplayFunction -> Identity],
{low, high} = ToString /@ FullOptions[ldp, PlotRange][[3]];
low = "<=" <> low;
{Hue[1 - #/2] &, 7, low, high, LegendPosition -> {1.1, -.4}}]];
Kind regards,
Hartmut Wolf