AW: ContourPlots,DensityPlots

• To: mathgroup at smc.vnet.net
• Subject: [mg23612] AW: [mg23558] ContourPlots,DensityPlots
• From: Wolf Hartmut <hwolf at debis.com>
• Date: Wed, 24 May 2000 02:16:12 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```
-----Ursprüngliche Nachricht-----
Von:	Paul Hoke [SMTP:hokepaul at pilot.msu.edu]
Gesendet am:	Samstag, 20. Mai 2000 09:11
An:	mathgroup at smc.vnet.net
Betreff:	[mg23558] ContourPlots,DensityPlots

Anybody have a lot of experience with ListContourPlot and
ListDensityPlot?

I have a matrix of data I want to plot and show for a presentation.

The problems I am having are as follows

with ColorFunctionScaling->True, It doesn't seem that the colors
have
any thing to do with the actual values if I use a legend and use
ColorFunction->Hue, the scale is on the plot doesn't equal the
legend
since the data is truncated to fit 0-1.

I'm trying to divide by the largest value since all my data is
positive
and then the legend color scheme should fit the data plot except I
don't
have a zero in my data to peg the lower end.  I hate to add a zero
in my
matrix just to fix the lower end of the color scheme, is that the
only
option?

I can delineate which contours I want, but I can't label them.  Is
there
anyway to print the value of contours?  That is on the plot have
each
contour marked so that it isn't just a bunch of lines?

Dear Paul,

I needed some guessing . . . but perhaps this example might help you:

Let's define some data

data = Table[Sin[x y] Cos[x] + 2, {y, 0, Pi, 0.2}, {x, 0, 2Pi,
0.2}];

{Min[data], Max[data]}
{1.00674, 2.9862}

(roughly between 1 and 3)
We color the density plot in a certain way

p = ListDensityPlot[data, MeshRange -> {{0, 2 Pi}, {0, Pi}},
ColorFunction -> (Hue[#/3] &), ColorFunctionScaling -> False]

So 1 corresponds to Hue[1/3] (green) and 3 corresponds to Hue[1] (red), all
other values are in between (blue, violet,  no yellow or orange). This is
reflected by the legend:

<< Graphics`Legend`

ShowLegend[  p,
{Hue[(2 # + 1)/3]&, 5, " 1", "3",
LegendPosition -> {1.1, -.4}}]

Why that (seemingly) different color function? within the legend the color
function is probed between 0 and 1 (in 5 steps here). So all we have to do
is to linearly map the interval {0, 1} to {min, max} of our applied color
function (when ColorFunctionScaling -> False).

So if you prefer to have the color scale at the legend reversed just do

ShowLegend[  p,
{Hue[(3 - 2 #)/3]&, 7, " 3", "1",
LegendPosition -> {1.1, -.4}}]

Kind regards,  Hartmut

```

• Prev by Date: Re: sending notebooks as attatchments with microsoft OutlookExpress...
• Next by Date: Re: BarChart Bug?
• Previous by thread: Re: , sending notebook attatchments, -- a partial solution...
• Next by thread: Re: ISING model