MathGroup Archive 2000

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

Search the Archive

Re: ContourPlot in arbitrary shape domain.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg21855] Re: [mg21815] ContourPlot in arbitrary shape domain.
  • From: "David Park" <djmp at earthlink.net>
  • Date: Wed, 2 Feb 2000 22:54:14 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Roberto and MathGroup,

One solution to plotting a contour plot in a constrained region is to use the Tom
Wickham-Jones ConstrainedContourPlot routine in his ExtendGraphics package. I believe
this is available from MathSource and it is also described in his book "Mathematica
Graphics". However, his routine allows only one constraint, and it appears to
suppress any contour shading, i.e., it just draws the contour lines.

Putting together rectangular regions, say in an L shape is not too difficult. Produce
the different plots and combine them in a show statement. However, you should specify
the same set of contours for all of the plots, and also specify the PlotRange for all
plots, using the same values for the "z" range. This is necessary to make the
separate plots mesh together properly.

Naturally, I find it easiest to do this using my DrawingPaper routine and ContourDraw
(available at my web site). But the problem intrigued me enough to add some
additional functionality. The basic contour plots must be made over a rectangular
region. The Wickham-Jones approach is to cut off the contour lines where they
intersect the constraint boundary. I tried a different approach. If we can specify a
coordinate system that matches the boundaries we want, we can make a rectangular plot
on that. Then we can transform the resulting graphical points back to a Cartesian
system. DrawingPaper has a routine DrawingTransform which makes it easy to do this.
Also it preserves the shading.

As an example, we could obtain a contour plot of f[x,y] in an annular ring by first
making a contour plot of f[r Cos[t], r Sin[t]] and then transforming to rectangular
coordinates. But my first attempt at this looked awful because the Polygons which
gave the shaded regions were poorly transformed. This was because the parts that met
the edges of the plot were given by long straight segments which needed to be
transformed smoothly into curves. So, I added a new routine to DrawingPaper called
PolygonFineGrain which allows one to specify when and how straight line segments in
polygons will be broken up into multiple segments. Once this is done, they transform
smoothly and nice contour plots in curved regions can be obtained. I have added an
illustration of this to the DrawingPaperTutorial.

This isn't a complete solution for every possible kind of region, but it should
greatly extend what can be done.

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/

>Hello!
>
>Sometimes I've to contour plotting a f(x,y) function on a
>domain other than rectangular (ring, L,U,T-shapes, multiconnected
>regions,etc.). An obvious solution is to subdivide the domain in
>rectangles and to paste all the relative contourplots by some
>external graphical program (or real scissors).
>Heavy work and poor results.
>There are not tricks or packages to improve ContourPlot[] function
>extending its use to regions defined by a set of equations ?
>I'd like something as
>
>ContourPlot[f[x,y],< set of xy-region specifications>]
>
>Many thanks in advance Roberto
>Dott. Roberto Brambilla
>ENEL PEA
>Via A.Volta, 1
>20093 Cologno Monzese (MI)
>tel +39.2.7224.5364
>fax +39.2.7224.5465
>bramrob at pea.enel.it
>





  • Prev by Date: RE: ContourPlot in arbitrary shape domain.
  • Next by Date: Re: Fitting a function to a list (newbie)
  • Previous by thread: RE: ContourPlot in arbitrary shape domain.
  • Next by thread: Re: Re: Could this be improved?---Continued