       Re: Extracting points from a contour plot

• To: mathgroup at smc.vnet.net
• Subject: [mg90409] Re: [mg90391] Extracting points from a contour plot
• From: "W_Craig Carter" <ccarter at mit.edu>
• Date: Tue, 8 Jul 2008 07:48:24 -0400 (EDT)
• References: <200807080626.CAA18073@smc.vnet.net>

```Hello AJ,
Instead of giving a single command, these steps to extract what you
want may be instructive:
cp = ContourPlot[Cos[x] + Cos[y] == 1/2, {x, 0, 4 Pi}, {y, 0, 4 Pi}]

cp // FullForm

p = Position[cp, _Line]

lines = Extract[cp, p]

verts = lines /. Line[a__] :> a

points = Extract[cp, Position[cp, _GraphicsComplex]][[1, 1]]

points is a list {{x1,y1},{x2,y2}... and lines is a list of
connections between those vertices {{index1,index4,index6..},{...}}
(see GraphicsComplex)

Good luck, WCC

On Tue, Jul 8, 2008 at 2:26 AM,  <ajfriend at gmail.com> wrote:
> I'm not a Mathematica expert, so hopefully this isn't too stupid of a
> question:
>
> 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.
>
> Any help would be great.
>
> Thanks,
> AJ
>
>

--
W. Craig Carter

```

• Prev by Date: Re: Extracting points from a contour plot
• Next by Date: Re: ReplaceAll
• Previous by thread: Extracting points from a contour plot
• Next by thread: Re: Extracting points from a contour plot