MathGroup Archive 2003

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

Search the Archive

Re: Area Between Contours in ContourPlot

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

In article <b3hs9r$iko$1 at>, John.Hornbuckle at 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 

  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.


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 

  • 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.