Re: Getting the plotted data from a graph
- To: mathgroup at smc.vnet.net
 - Subject: [mg131213] Re: Getting the plotted data from a graph
 - From: Themis Matsoukas <tmatsoukas at me.com>
 - Date: Mon, 17 Jun 2013 06:30:32 -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
 
> 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"},
> "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!
> 
> Thank you for your help in advance!
> 
> Best,
> Lily
> 
If you do 
FullForm[g1] 
you will see that the data are nested inside Line[...] in the form of x-y pairs. Here is one way to get them out:
g1 = Plot[Sin[x], {x, -Pi, Pi}, Frame -> True, 
  FrameLabel -> {"x", "y"}, ImageSize -> 2.6*72]
data = Flatten[List @@ g1[[1, 1, 3, 2]], 1];
ListPlot[data]
Themis