MathGroup Archive 1995

[Date Index] [Thread Index] [Author Index]

Search the Archive

Extracting data points from Plot[]

  • To: mathgroup at christensen.cybernetics.net
  • Subject: [mg773] Extracting data points from Plot[]
  • From: j-guyer at nwu.edu (Jon Guyer)
  • Date: Thu, 13 Apr 1995 14:10:52 -0500
  • Organization: Northwestern University, Evanston, IL

The Plot[] function does some intelligent picking of points, such that it
usually does a pretty good job of following twists and turns in a function
without plotting an excessive number of points. I'm not ecstatic about
using Mma for final output, though, so I like to export these curves to a
graphing program.

So far, I haven't been able to figure out any way to get at this
point-picking algorithm without using Plot[]. What I'm then left with is
doing:

In[1]:= Plot[{x,x^2},{x,0,2}];

In[2]:= InputForm[%1][[1]][[1]][[1]][[1]][[1]][[1]]

Out[2]= {{0., 0.}, {0.0833333, 0.0833333}, {0.166667, 0.166667},

>    {0.25, 0.25}, {0.333333, 0.333333}, {0.416667, 0.416667}, {0.5, 0.5},

>    {0.583333, 0.583333}, {0.666667, 0.666667}, {0.75, 0.75},

>    {0.833333, 0.833333}, {0.916667, 0.916667}, {1., 1.},

>    {1.08333, 1.08333}, {1.16667, 1.16667}, {1.25, 1.25},

>    {1.33333, 1.33333}, {1.41667, 1.41667}, {1.5, 1.5}, {1.58333, 1.58333},

>    {1.66667, 1.66667}, {1.75, 1.75}, {1.83333, 1.83333},

>    {1.91667, 1.91667}, {2., 2.}}

In[3]:= InputForm[%1][[1]][[1]][[2]][[1]][[1]][[1]]

                                          -6
Out[3]= {{0., 0.}, {0.00260417, 6.78168 10  }, {0.00520833, 0.0000271267},

>    {0.0078125, 0.0000610352}, {0.0104167, 0.000108507},

>    {0.0130208, 0.000169542}, {0.015625, 0.000244141},

>    {0.0208333, 0.000434028}, {0.0260417, 0.000678168},

>    {0.03125, 0.000976562}, {0.0416667, 0.00173611},

>    {0.0520833, 0.00271267}, {0.0625, 0.00390625}, {0.0833333, 0.00694444},

>    {0.104167, 0.0108507}, {0.125, 0.015625}, {0.166667, 0.0277778},

>    {0.208333, 0.0434028}, {0.25, 0.0625}, {0.333333, 0.111111},

>    {0.416667, 0.173611}, {0.5, 0.25}, {0.583333, 0.340278},

>    {0.666667, 0.444444}, {0.75, 0.5625}, {0.833333, 0.694444},

>    {0.916667, 0.840278}, {1., 1.}, {1.08333, 1.17361}, {1.16667, 1.36111},

>    {1.25, 1.5625}, {1.33333, 1.77778}, {1.41667, 2.00694}, {1.5, 2.25},

>    {1.58333, 2.50694}, {1.66667, 2.77778}, {1.75, 3.0625},

>    {1.83333, 3.36111}, {1.91667, 3.67361}, {2., 4.}}



I can then export this to a useably formatted text file of data with an
arcane little macro I got from somebody.

What I'm wondering, though, is if there isn't something a bit more
straightforward than "InputForm[%1][[1]][[1]][[2]][[1]][[1]][[1]]" to get
at the data points?  Is there a way to generate these data series the way
Plot[] does, without using Plot (which necessitates stripping off the
"Graphics" and "Line" structures which make up the bulk of the
sub-sub-sub-arrays that I'm referencing).

Am I being obtuse?

-- 
Jonathan E. Guyer                        j-guyer at nwu.edu


  • Prev by Date: P:Re: FactorInteger Print Formatting
  • Next by Date: Re: Accuracy and Precision
  • Previous by thread: P:Re: FactorInteger Print Formatting
  • Next by thread: Re: Extracting data points from Plot[]