       Re: Getting the plotted data from a graph

• To: mathgroup at smc.vnet.net
• Subject: [mg131191] Re: Getting the plotted data from a graph
• From: W Craig Carter <ccarter at MIT.EDU>
• Date: Sun, 16 Jun 2013 05:19:35 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• Delivered-to: l-mathgroup@wolfram.com
• Delivered-to: mathgroup-outx@smc.vnet.net
• Delivered-to: mathgroup-newsendx@smc.vnet.net
• References: <20130615082448.BFAE16A7C@smc.vnet.net>

```Hello Lily,
This should do what you are looking for:

plot = Plot[Sin[x], {x, -Pi, Pi}, PlotStyle -> None, Axes -> False,
Mesh -> All, MeshStyle -> Directive[PointSize[Medium]]]

points = Flatten[Cases[plot, GraphicsComplex[a_, ___] -> a, Infinity],
1]

W Craig Carter
Professor of Materials Science, MIT

On Jun 15, 13, at 4:24 AM, Lily T. wrote:

> Dear All,
>
> My question is regarding the plotted data points in a graph. Assume =
you draw a graph of sinx as:
>
> g1 = Plot[Sin[x], {x, -Pi, Pi},
>      Frame -> True, FrameLabel -> {"x", "y"}, ImageSize -> 2.6*72
>    ]
>
> then how can I get all of the data points of this graph by using =
mathematica?
>
> This is really important for me and I couldn't find the answer =
anywhere online!
>