MathGroup Archive 2009

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

Search the Archive

Re: Define a function as a graphics directive?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105044] Re: Define a function as a graphics directive?
  • From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
  • Date: Thu, 19 Nov 2009 05:22:00 -0500 (EST)
  • References: <he0ngh$43r$1@smc.vnet.net>

I don't know of an easy way to do this directly, but the following
workaround works for me.

Show[
 Table[
  ContourPlot[z Exp[-Sqrt[z^2 + x^2]/2.], {x, -10, 10}, {z, -10, 10},
   ContourShading -> None, Contours -> {c},
   ContourStyle -> {{Switch[Sign[c], 1, Black, -1, Red, 0, Blue],
      Thick}}], {c, -1/2, 1/2, 1/10}]]

Cheers -- Sjoerd

On Nov 18, 1:58 pm, Porscha Louise McRobbie <pmcro... at umich.edu>
wrote:
> Hi,
>
> I have a very simple contour plot:
>
> ContourPlot[ z Exp[-Sqrt[z^2 + x^2]/2.], {x, -10, 10}, {z, -10, 10},
>   ContourShading -> None, Contours -> 15,
>   ContourStyle -> {{Black, Thick}}]
>
> I do not want the plot shaded, but I want to color the contour lines  
> according to  a function of z (e.g., Sign[z], where z>0 is black, z<0 
> is red). Can this be done within ContourStyle?
>
> I tried putting a function definition for the color inside  
> ContourShading, but I get an error since it's not a graphics directive 
> (and it's my understanding that ColorFunction is only for shading the  
> regions between contours).
>
> Thanks for any input!
> Porscha



  • Prev by Date: Re: Define a function as a graphics directive?
  • Next by Date: Re: Changing variables within a differential equation
  • Previous by thread: Re: Define a function as a graphics directive?
  • Next by thread: Re: Define a function as a graphics directive?