       Re: Contour Lines

• To: mathgroup at smc.vnet.net
• Subject: [mg83609] Re: Contour Lines
• From: "David Park" <djmpark at comcast.net>
• Date: Sat, 24 Nov 2007 04:17:26 -0500 (EST)
• References: <fi6b6f\$q2e\$1@smc.vnet.net>

```Let's assume that you are working with Version 6.

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

We have to apply Normal to the graphics primitives to obtain the line with
the actual coordinates in it.

contourline =
First[Cases[First[plot1] // Normal,
Line[pts_] -> pts, \[Infinity]]];

We can check it with:

ListPlot[contourline, Joined -> True]

--
David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/

"Wyn Evans" <nwe at ast.cam.ac.uk> wrote in message
news:fi6b6f\$q2e\$1 at smc.vnet.net...
>
> How do you extract the coordinates of points making up a Contour Line as
> a List?
>
> This has been dealt with before in the archive (see e.g., )
> but the code there seems no longer to work. For example, the following is
> suggested
>
> 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}];
> 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)
>
>
> I can see that the data I want (the actual coordinates) is there, but I
> can't figure how to extract it as a matrix or list.
>
>
>

```

• Prev by Date: Possible bug in HamiltonianCycle
• Next by Date: Re: Button[label, action] Change Font?
• Previous by thread: Re: Contour Lines
• Next by thread: Re: Contour Lines