Michael, Sorry, surface is for rectangular grids only. Quoting the manual "Draws a surface of a rectangular grid. Each rectangle is divided into 4 triangles."
You can use points and lines for any kind of data, but this might not at all
help you. However, graphxyz might still be useful to you: You can use it for
conversion of 3-dimensional points to two dimensions (with all the features
like easily rotate the coordinate system, change projectors, etc.). Here's an
example:
from pyx import *
from math import sin, cos, pi
g = graph.graphxyz(size=4, x=graph.axis.linear(min=-1,max=1),
y=graph.axis.linear(min=-1,max=1),z=graph.axis.linear(min=-1,max=1))
Ax, Ay = g.pos(-1,-1,-1)
Bx, By = g.pos(-1,1,-1)
Cx, Cy = g.pos(1,1,-1)
Dx, Dy = g.pos(1,-1,-1)
Ex, Ey = g.pos(-1,-1,1)
Fx, Fy = g.pos(-1,1,1)
Gx, Gy = g.pos(1,1,1)
Hx, Hy = g.pos(1,-1,1)
c = canvas.canvas()
c.stroke(path.line(Ax, Ay, Bx, By))
c.stroke(path.line(Bx, By, Cx, Cy))
c.stroke(path.line(Cx, Cy, Dx, Dy))
c.stroke(path.line(Dx, Dy, Ax, Ay))
c.stroke(path.line(Ex, Ey, Fx, Fy))
c.stroke(path.line(Fx, Fy, Gx, Gy))
c.stroke(path.line(Gx, Gy, Hx, Hy))
c.stroke(path.line(Hx, Hy, Ex, Ey))
c.stroke(path.line(Ax, Ay, Ex, Ey))
c.stroke(path.line(Bx, By, Fx, Fy))
c.stroke(path.line(Cx, Cy, Gx, Gy))
c.stroke(path.line(Dx, Dy, Hx, Hy))
c.writePDFfile(__file__[:-3])
(I just found a bug in the pos methods, hence you need to fetch the current svn
HEAD to use this functionality. However, I always planed to make this possible
on the graphxyz -- just missed to properly test this functionality. Note that
you need the graphxyz here, as the projectors themselfs are not able to define
the coordinate system. You need axes for that. As shown in the example you may
draw on a separate canvas. You may, however, also stroke the on the graph and
write the graph to a file. Than the axis are shown (according to their painters
setting).)
Best,
André
Am 21.06.2010 um 18:17 schrieb Michael J Gruber:
> I'm getting somewhat frustrated with the graphxyz interface (or my
> understanding thereof).
>
> For good measure, I'm trying to plot a sphere. Now, no matter what I do,
> there seems to be some clipping/whatever going on which deletes points
> from my supplied list of points.
>
> The code below works for simple expressions like "p, sin(t), sin(t)" but
> not for the one below nor for the one commented out (sphere). I tried
> setting the axes ranges so that nothing should get clipped/removed. Why
> are nodes being deleted? (Tested with 0.10 as well as trunk.)
>
> Hoping for help...
> Michael
>
>
> from pyx import *
> from math import sin, cos, pi
>
> N = 10
> g = graph.graphxyz(size=4, x=graph.axis.linear(min=-1,max=1),
> y=graph.axis.linear(min=-1,max=1),z=graph.axis.linear(min=-1,max=1))
>
> ps = [ 2*pi*i/N for i in range(N+1) ]
> ts = [ pi*i/N for i in range(N+1) ]
>
> #xyz = [ [cos(t)*cos(p), cos(t)*sin(p), sin(t)] for t in ts for p in ps]
> xyz = [ [cos(p), sin(p), sin(t)] for t in ts for p in ps]
> g.plot(graph.data.points(xyz,
> x=1, y=2, z=3),
> [graph.style.surface(backcolor=None,gridcolor=color.gray.black)])
>
> g.writePDFfile(__file__[:-3])
>
>
> /usr/lib64/python2.6/site-packages/pyx/text.py:888: DeprecationWarning:
> os.popen4 is deprecated. Use the subprocess module.
> self.texinput, self.texoutput = os.popen4("%s%s %s" % (self.mode,
> ipcflag, self.texfilename), "t", 0)
> Traceback (most recent call last):
> File "kugel.py", line 15, in <module>
> g.writePDFfile(__file__[:-3])
> File "/usr/lib64/python2.6/site-packages/pyx/canvas.py", line 330, in
> wrappedindocument
> return method(d, file)
> File "/usr/lib64/python2.6/site-packages/pyx/document.py", line 161,
> in writePDFfile
> pdfwriter.PDFwriter(self, file, *args, **kwargs)
> File "/usr/lib64/python2.6/site-packages/pyx/pdfwriter.py", line 475,
> in __init__
> catalog = PDFcatalog(document, self, registry)
> File "/usr/lib64/python2.6/site-packages/pyx/pdfwriter.py", line 155,
> in __init__
> self.PDFpages = PDFpages(document, writer, registry)
> File "/usr/lib64/python2.6/site-packages/pyx/pdfwriter.py", line 212,
> in __init__
> page = PDFpage(page, pageno, self, writer, registry)
> File "/usr/lib64/python2.6/site-packages/pyx/pdfwriter.py", line 238,
> in __init__
> self.PDFcontent = PDFcontent(page, writer, self.pageregistry)
> File "/usr/lib64/python2.6/site-packages/pyx/pdfwriter.py", line 267,
> in __init__
> page.processPDF(contentfile, writer, acontext, registry, self.bbox)
> File "/usr/lib64/python2.6/site-packages/pyx/document.py", line 141,
> in processPDF
> self._process("processPDF", *args)
> File "/usr/lib64/python2.6/site-packages/pyx/document.py", line 81, in
> _process
> getattr(self.canvas, processMethod)(canvasfile, writer, context,
> registry, bbox)
> File "/usr/lib64/python2.6/site-packages/pyx/graph/graph.py", line
> 167, in processPDF
> canvas.canvas.processPDF(self, file, writer, context, registry, bbox)
> File "/usr/lib64/python2.6/site-packages/pyx/canvas.py", line 216, in
> processPDF
> item.processPDF(file, writer, context, registry, nbbox)
> File "/usr/lib64/python2.6/site-packages/pyx/mesh.py", line 127, in
> processPDF
> thisbbox = self.bbox()
> File "/usr/lib64/python2.6/site-packages/pyx/mesh.py", line 99, in bbox
> return bbox.bbox_pt(min([node.coords_pt[0] for element in
> self.elements for node in element.nodes]),
> ValueError: min() arg is an empty sequence
>
>
> ------------------------------------------------------------------------------
> ThinkGeek and WIRED's GeekDad team up for the Ultimate
> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
> lucky parental unit. See the prize list and enter to win:
> http://p.sf.net/sfu/thinkgeek-promo
> _______________________________________________
> PyX-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/pyx-user
--
by _ _ _ Dr. André Wobst, Amselweg 22, 85716 Unterschleißheim
/ \ \ / ) [email protected], http://www.wobsta.de/
/ _ \ \/\/ / PyX - High quality PostScript and PDF figures
(_/ \_)_/\_/ with Python & TeX: visit http://pyx.sourceforge.net/
smime.p7s
Description: S/MIME cryptographic signature
------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________ PyX-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/pyx-user
