Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

RE: ContourPlot and finite approximation to level sets

  • To: mathgroup at
  • Subject: [mg68657] RE: [mg68629] ContourPlot and finite approximation to level sets
  • From: "David Park" <djmp at>
  • Date: Mon, 14 Aug 2006 06:44:42 -0400 (EDT)
  • Sender: owner-wri-mathgroup at


You can do this by extracting the data points from the plot and then using
SplineFit on the points. Here I will extract a single contour for an

f[x_, y_] := x^2 + 2y^2
plot1 = ContourPlot[f[x, y], {x, -2, 2}, {y, -2, 2}, Contours -> {1},
      ContourShading -> False, PlotPoints -> {30, 30}];

Convert the ContourGraphics to Graphics and then extract the first part and
you will see how Mathematica represents the contours.

contour = First@Graphics@plot1
(output omitted)

Extract the points from contour.

cdata = First@Cases[contour, Line[pts_] -> pts, \[Infinity]]
(output omitted)

Now load the SplinFit package.


cfunction = SplineFit[cdata, Cubic]
SplineFunction["Cubic", "{0., 48.}", <>]

The domain of the parameter for the function is 0 <= t <= 48. You can get a
point on the contour by, for example,

{0.482759, -0.619284}

and as a check we could plot it using ParametricPlot.

ParametricPlot[cfunction[t], {t, 0, 48},
    AspectRatio -> Automatic];

David Park
djmp at

From: dkjk at [mailto:dkjk at]
To: mathgroup at

Hi all,

Given a real-valued function f(x,y) over {(x,y) | xmin < x < xmax, ymin
< y < ymax}, ContourPlot can be used to generate the graph of the level
set { (x,y) | f(x,y) = c } using


Is there any way to access the coordinates used by Mathematica to paint
the contour line of height c? If not, can anyone suggest an algorithm,
such as the one used by Mathematica, to finitely approximate a level

Thanks very much in advance,


  • Prev by Date: Re: Hyperlink to *.pdf File
  • Next by Date: Re: a Quaternion quadratic level Pisot polynomial
  • Previous by thread: Re: ContourPlot and finite approximation to level sets
  • Next by thread: Re: ContourPlot and finite approximation to level sets