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: [mg105078] Re: Define a function as a graphics directive?
  • From: fd <fdimer at gmail.com>
  • Date: Fri, 20 Nov 2009 06:38:41 -0500 (EST)
  • References: <he0ngh$43r$1@smc.vnet.net> <he3e6q$jau$1@smc.vnet.net>

On Nov 19, 11:37 pm, Harrie Kraai <hakr... at xs4all.nl> wrote:
> 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

Hi Again..

Just forgot to suggest a solution that involves RegionPlot. You'll
need to work a few more details, but in essence it is


f[z_, x_] = z Exp[-Sqrt[z^2 + x^2]/2.];



lf = #1 < f[x, y] < #2 & @@@
  Table[{ii, ii + 0.05}, {ii, -0.6, 0.6, 0.2}]


RegionPlot[lf, {x, -10, 10}, {y, -10, 10},
 ColorFunction -> Function[{x, y}, Hue[f[x, y] + 0.5]],
 PerformanceGoal -> "Quality", PlotPoints -> 100]


Best
F







  • Prev by Date: More Efficient Method
  • Next by Date: Re: Dynamic Control of Graphics
  • Previous by thread: Re: Define a function as a graphics directive?
  • Next by thread: subscripts in function definitions