Drexel dragonThe Math ForumDonate to the Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Getting the plotted data from a graph
Replies: 5   Last Post: Jun 17, 2013 6:18 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Bob Hanlon

Posts: 906
Registered: 10/29/11
Re: Getting the plotted data from a graph
Posted: Jun 16, 2013 5:11 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

g1 = Plot[Sin[x], {x, -Pi, Pi},
Frame -> True,
FrameLabel -> {"x", "y"},
ImageSize -> 2.6*72]

g1Pts = Cases[g1, Line[pts_] :> pts, Infinity];

g2 = ListLinePlot[g1Pts,
Frame -> True,
FrameLabel -> {"x", "y"},
ImageSize -> 2.6*72]

You can directly access the associated Part of g1; however, the specific
Part (position of Line) varies between plot types; whereas, locating the
Line with Cases works the same.

g1Pts ==
List @@ g1[[1, 1, 3, 2]] ==
Cases[g2, Line[pts_] :> pts, Infinity] ==
List @@ g2[[1, 2, 1, 3, 3]]


Bob Hanlon

On Sat, Jun 15, 2013 at 4:24 AM, Lily T. <econactually@gmail.com> 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!
> Thank you for your help in advance!
> Best,
> Lily

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2015. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.