MathGroup Archive 2003

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

Search the Archive

Re: Area Between Contours in ContourPlot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg39662] Re: Area Between Contours in ContourPlot
  • From: Paul Abbott <paul at physics.uwa.edu.au>
  • Date: Fri, 28 Feb 2003 04:45:29 -0500 (EST)
  • Organization: The University of Western Australia
  • References: <b3hs9r$iko$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

In article <b3hs9r$iko$1 at smc.vnet.net>, John.Hornbuckle at csiro.au wrote:

> I have a contourplot of a function and wish to find the area between certain
> contours contained within the plot. Is there a standard function in 
> Mathematica which will do this? 

There is no standard function to do this. However, it is not too hard to 
do what you want. Here is a contour plot. 

  cp = ContourPlot[x^4 + 2x y + y^2, {x, -2, 2}, {y, -3, 3},     
   Contours -> {1/2, 1, 2}, PlotPoints -> 100]; 

First we need to extract the contour lines from this plot, as a set of 
points.

  contours = Cases[Graphics[cp], Line[a__] :> a, Infinity]

Then we compute the (approximate) area enclosed within each (closed) 
contour by triangulation:

 (#[[All,1]] . RotateLeft[#[[All,2]]] - 
  #[[All,2]] . RotateLeft[#[[All,1]]])/2 & ) /@ contours

Note that the PlotPoints option controls how many points there are in 
each contour.

Cheers,
Paul

-- 
Paul Abbott                                   Phone: +61 8 9380 2734
School of Physics, M013                         Fax: +61 8 9380 1014
The University of Western Australia      (CRICOS Provider No 00126G)         
35 Stirling Highway
Crawley WA 6009                      mailto:paul at physics.uwa.edu.au 
AUSTRALIA                            http://physics.uwa.edu.au/~paul



  • Prev by Date: Re: Re: Integration of Exp[-x^2]/(1 + Exp[a * x])
  • Next by Date: Re: Re: DigitBlock problem
  • Previous by thread: Re: Area Between Contours in ContourPlot
  • Next by thread: visualizing Map, Thread, Apply, etc.