MathGroup Archive 2009

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

Search the Archive

Re: Multiple conditions in ContourPlot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg103028] Re: [mg102999] Multiple conditions in ContourPlot
  • From: "David Park" <djmpark at comcast.net>
  • Date: Fri, 4 Sep 2009 03:16:38 -0400 (EDT)
  • References: <11985823.1252022604058.JavaMail.root@n11>

Basically, use the RegionFunction option to put in extra conditions.

f := Function[z, z^2 Sin[z] Cos[z]]
ContourPlot[Im[f[x + I y]] == 0, {x, -5, 5}, {y, -5, 5},
 RegionFunction -> Function[{x, y}, Re[f[x + I y]] > 0]]


Just for fun, here is a fancier plot of the same function using
Presentations. The Re positive regions are colored light blue, the negative
regions are colored light pink, the Im zero contourlines are black in the
positive regions and a very faint gray in the negative regions.

Needs["Presentations`Master`"]

With[
 {f = Function[z, z^2 Sin[z] Cos[z]],
  zmin = -5 (1 + I),
  zmax = 5 (1 + I)},
 Draw2D[
  {RegionDraw[Re[f[x + I y]] > 0, {x, -5, 5}, {y, -5, 5},
    PlotStyle -> LightBlue,
    BoundaryStyle -> None],
   RegionDraw[Re[f[x + I y]] < 0, {x, -5, 5}, {y, -5, 5},
    PlotStyle -> LightPink,
    BoundaryStyle -> None],
   Black,
   ComplexCartesianContour[Im[f[z]] == 0, {z, zmin, zmax},
    ContourLabels -> Automatic,
    RegionFunction -> Function[{x, y}, Re[f[x + I y]] > 0]],
   GrayLevel[0.8],
   ComplexCartesianContour[Im[f[z]] == 0, {z, zmin, zmax},
    ContourLabels -> Automatic,
    RegionFunction -> Function[{x, y}, Re[f[x + I y]] < 0]]},
  Frame -> True, FrameLabel -> {Re, Im},
  PlotLabel -> Row[{Im["f[z]"] == 0}],
  ImageSize -> 300]
 ]


David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/  

From: Theo Moore [mailto:tsg.moore at googlemail.com] 

Suppose I had a function f[z] and I wanted to plot the contour such
that the imaginary part of f[z] is zero and the real part is positive.
I thought I could use:

ContourPlot[ (Im[f[x + y*I] == 0) && (Re[f[x + y*I] >= 0), {x, -5, 5},
{y, -5, 5}]

But it does not work.

I can do it using only one. For example,

ContourPlot[Im[f[x + y*I] == 0, {x, -5, 5}, {y, -5, 5}]

But how do  you use multiple logical conditions?




  • Prev by Date: Re: Re: Mapping to a specific column or row in a matrix
  • Next by Date: Re: how to solve the integer equation Abs[3^x-2^y]=1
  • Previous by thread: Multiple conditions in ContourPlot
  • Next by thread: Significant Digits in Mathematica in Excel