MathGroup Archive 2008

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

Search the Archive

Re: Extracting points from a contour plot

  • To: mathgroup at
  • Subject: [mg90408] Re: Extracting points from a contour plot
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at>
  • Date: Tue, 8 Jul 2008 07:48:12 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <g4v34e$ihi$>

ajfriend at wrote:

> I'm using ContourPlot to plot the curve of zeros of a function of two
> variables within a range of vales (0 < x < 1, 0 < y < 1). Now, what I
> really want is the list of points that it generates. I've tried
> playing with Solve and NSolve, but these are either not working or are
> taking too long. What is the easiest way of getting at the list of
> points that ContourPlot has generated? Do I have to do something like
> InputForm[%] and then cut and paste the list that I want, or is there
> some easier way of doing it?
> Or, maybe there is a way of getting the points that I want without
> using ContourPlot that I haven't come across yet, or maybe I'm just
> not using Solve correctly.

Say we want to investigate the following equation. Looking at the 
*FullForm* of the graph, we can see that the points computed by 
ContourPlot are the first element (list of lists) of a GraphicsComplex 
structure. We use *Cases* to extract the list of pairs and check that 
the sampled points are indeed roots of the equation.

(Note that we can also use *Reduce* to get a set of analytic solutions.)

   g = ContourPlot[Cos[x] + Cos[y] == 0, {x, 0, 2 Pi}, {y, 0, 2 Pi}]


   pts = First@Cases[g, x_GraphicsComplex :> First[x]]

   MapThread[Chop[Cos[#1] + Cos[#2]] == 0 &, Transpose@pts]

   Reduce[Cos[x] + Cos[y] == 0 && 0 <= x <= 2 Pi && 0 <= y <= 2 Pi, {x,

-- Jean-Marc

  • Prev by Date: Re: running multiple mathkernel's
  • Next by Date: VectorFieldPlot scaling
  • Previous by thread: Re: Extracting points from a contour plot
  • Next by thread: Fwd: Extracting points from a contour plot