Re: Define a function as a graphics directive?
- To: mathgroup at smc.vnet.net
- Subject: [mg105066] Re: Define a function as a graphics directive?
- From: Harrie Kraai <hakraai at xs4all.nl>
- Date: Thu, 19 Nov 2009 07:25:05 -0500 (EST)
- References: <he0ngh$43r$1@smc.vnet.net>
Hi,
My quick solution would be this:
cpl = ContourPlot[
z Exp[-Sqrt[z^2 + x^2]/2.], {x, -10, 10}, {z, -10, 10},
ContourShading -> None, Contours -> 15, ContourStyle -> {Thick}];
cpl /. {tt_Tooltip :> Sequence[If[tt[[2]] > 0, Black, Red], tt]}
which makes use of the fact that the tooltip contains the value of the
contourline
Have fun,
HK
Porscha Louise McRobbie 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
>
>
>
>
>