MathGroup Archive 2004

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

Search the Archive

RE: Plotting a contour plot with cylindrical co-ordinates

Mathematica basically make rectangular contour plots. But it is possible to
make a rectangular contour plot in the r-theta plane, grab the primitive
graphics, and transform them to the xy-plane to obtain a circular contour

The DrawGraphics package at my web site below contains all the routines
needed for doing this. First, DrawGraphics deals directly with primitive
graphics so there is no problem in working with them. One problem that
occurs in making these transformations is that long straight line segments
must be broken into multiple points. These straight line segments generally
occur on the edge of the rectangular contour plot. They can be broken up
with the FineGrainPolygons routine. Without fine graining the segments will
not bend. Then the DrawingTransform routine can be used to transform from
polar to cartesian coordinates.

Here is an example that works with a function. In your case you could use
ListContourDraw with data instead of ContourDraw with a function. (These
routines work just like ListContourPlot and ContourPlot except that they
return the primitive graphics without a side plot.)

DrawingTransform takes pure functions as its arguments. These give the new
coordinates in terms of the old coordinates.


f[r_, \[Theta]_] := (2 - 3*r + r^2)*Cos[2*\[Theta]]

    {(ContourDraw[f[r, \[Theta]], {r, 0, 1.5}, {\[Theta], 0, 2\[Pi]},
              ColorFunction -> Hue, PlotPoints -> 50] //
            FineGrainPolygons[0.3, 4]) /.
        DrawingTransform[#1 Cos[#2] &, #1Sin[#2] &],
      Circle[{0, 0}, 1.5]},
    PlotRange -> All,
    AspectRatio -> Automatic];

This gives a smooth circular contour plot of the function in the xy-plane.

David Park
djmp at

From: Jake [mailto:luckyjake3000 at]
To: mathgroup at

I have a set of data which corresponds to points on a circle. I have
these values as a function of r and theta. Is there a way of plotting
this in Mathematica? The ContourPlot function requires x and y
Please help if you know.

  • Prev by Date: Re: Plotting a function and its derivative
  • Next by Date: Re: Plotting a function and its derivative
  • Previous by thread: Re: Plotting a contour plot with cylindrical co-ordinates
  • Next by thread: RE: Plotting a contour plot with cylindrical co-ordinates