MathGroup Archive 2005

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

Search the Archive

Re: Does ContourPlot behave correctly?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg59860] Re: [mg59822] Does ContourPlot behave correctly?
  • From: "David Park" <djmp at earthlink.net>
  • Date: Wed, 24 Aug 2005 06:30:36 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Vlad,

It looks all right to me. Often it is easier to see what is happening with an animation. Here I use Hue instead of GrayLevel. And since the function varies between 1 and 0 I used ColorFunctionScaling -> False.

Needs["Graphics`Animation`"]

frame[c2_] := ContourPlot[E^((-(1/2))*(x^2 + y^2)), {x, -1, 1}, 
    {y, -1, 1}, Contours -> {0.39, c2, 0.95}, ColorFunction -> Hue, 
    ColorFunctionScaling -> False, PlotPoints -> 100];  

Animate[frame[c2], {c2, 0.4, 0.95, 0.025}]
SelectionMove[EvaluationNotebook[], All, GeneratedCell]
FrontEndTokenExecute["OpenCloseGroup"]; Pause[0.5];
FrontEndExecute[{FrontEnd`SelectionAnimate[200, AnimationDisplayTime -> 0.1, 
      AnimationDirection -> ForwardBackward]}]

The outer and inner contours stay fixed, and the middle contour moves between them. What is confusing is that the two middle colors, or gray levels if you used that, change as the contour moves.

In the following I use a custom color function that breaks the colors according to the middle contour.

colorfunc[c2_][z_] :=
  Which[
    z <= 0.39, Hue[0.0],
    0.39 < z <= c2, Hue[0.3],
    c2 < z <= 0.95, Hue[0.6],
    z > 0.95, Hue[0.9]]

frame[c2_] := ContourPlot[E^((-(1/2))*(x^2 + y^2)), {x, -1.5, 1.5}, 
    {y, -1.5, 1.5}, Contours -> {0.39, c2, 0.95}, 
    ColorFunction -> colorfunc[c2], ColorFunctionScaling -> False, 
    PlotPoints -> 100]; 

Animate[frame[c2], {c2, 0.4, 0.95, 0.025}]
SelectionMove[EvaluationNotebook[], All, GeneratedCell]
FrontEndTokenExecute["OpenCloseGroup"]; Pause[0.5];
FrontEndExecute[{FrontEnd`SelectionAnimate[200, AnimationDisplayTime -> 0.1, 
      AnimationDirection -> ForwardBackward]}]

Now the colors are perfectly stable and the middle contour moves continuously between the inner and outer contour.

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/ 




From: Vladislav [mailto:kazimir04 at yahoo.co.uk]
To: mathgroup at smc.vnet.net


Hello,

I try two commands, the only difference being .9 in lieu of .5 in the
Contours option.

ContourPlot[Exp[-(x^2 +
    y^2)/2], {x, -1, 1}, {y, -1, 1},
      Contours -> {.39, .5, .95},
      ColorFunction -> (
      GrayLevel[#1] &), PlotPoints -> 100];

ContourPlot[Exp[-(x^2 +
    y^2)/2], {x, -1, 1}, {y, -1, 1},
      Contours -> {.39, .9, .95},
      ColorFunction -> (GrayLevel[#1] &),
      PlotPoints -> 100];


I obtain two different plots. The smallest circle is the same for the
two pictures, it is OK becouse it corresponds to the Contor at 0.95.

I expected to have 3 circle on the two pictures with the only
difference in the second circle at .9 or .5. In reallity, I have only
two circles in the first plot and three circles in the second one.
Moreover the external contour at .39 is not the same in the two
pictures.

Can anybody explain or justify this behavoir?

Vlad



  • Prev by Date: Re: Simplifying Conjugate[] with 5.2 Mac
  • Next by Date: Re: Simplifying Conjugate[] with 5.2 Mac
  • Previous by thread: Re: Does ContourPlot behave correctly?
  • Next by thread: Distribution and Integral