MathGroup Archive 2000

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

Search the Archive

AW: ContourPlots,DensityPlots

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

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

	Anybody have a lot of experience with ListContourPlot and 

	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
	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
	since the data is truncated to fit 0-1.

	I'm trying to divide by the largest value since all my data is
	and then the legend color scheme should fit the data plot except I
	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

	I can delineate which contours I want, but I can't label them.  Is
	anyway to print the value of contours?  That is on the plot have
	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,

	{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