On Wed, 27 Aug 2008 at 05:18PM -0700, Mike Hansen wrote: > Hi Dan, > > On Wed, Aug 27, 2008 at 5:13 PM, Dan Drake <[EMAIL PROTECTED]> wrote: > > The "Plotting functions with asymptotes" thread reminded me of something > > I've wondered for a while: is it possible to get access to the list of > > points that a plot object uses? It's easy enough to make up my own list, > > with something like > > > > ... > > > > Is this possible right now? Or do I smell a trac ticket? :) > > > > Dan > > You can get at this now. > > sage: p = plot(sin, -4, 4) > sage: p[0].xdata[:5] > > [-4.0, > -3.9983470781843895, > -3.9966941563687794, > -3.9950412345531694, > -3.9933883127375589]
Excellent! I see there is also a ydata.
For the sake of the hive mind, here's how to achieve what I was asking
for. TikZ wants a file with each line an (x,y) pair with a space between
them. (See section 18.4 of the PGF/TikZ manual.) So you can do:
f = open('somefile', 'w')
points = plot(sin, -4, 4)[0]
f.write('# Plot of sine from -4 to 4.\n')
for point in zip(points.xdata, points.ydata):
f.write('%f %f\n' % point)
f.close()
and then in your document, do this inside a TikZ picture:
\tikz \draw plot[smooth] file {somefile};
Dan
--
--- Dan Drake <[EMAIL PROTECTED]>
----- KAIST Department of Mathematical Sciences
------- http://math.kaist.ac.kr/~drake
signature.asc
Description: Digital signature
