From: Andre W. <wo...@us...> - 2005-02-10 06:03:29
|
Hi, On 09.02.05, Joerg Lehmann wrote: > See the attached example how to do this. I think this is just about the right time to create a graphstyle example directory. We really should show to the people, how easy they can construct and work with own graph styles. > from pyx import * > > # The new symbol: just a vertical line > # > # Note that, as for all internal PyX methods, coordinates are passed in PS > # points, and we hence have to use the corresponding path classes. > def _linesymbol(c, x_pt, y_pt, size_pt, attrs): > c.draw(path.line_pt(x_pt, y_pt-0.5*size_pt, x_pt, y_pt+0.5*size_pt), attrs) > > # the symbol style expects a changeable attribute as argument, > # so we create a dummy one consisting of a single symbol > linesymbol = attr.changelist([_linesymbol]) Note that you never need to plug in changeable attributes when you don't want to have it changed. > # example usage > g = graph.graphxy(width=10, > x=graph.axis.lin(min=0, max=10)) > > g.plot(graph.data.function("y=x**2"), [graph.style.symbol(symbol=linesymbol)]) You could use _linesymbol directly here as well ... > g.writeEPSfile(__file__[:-3]) The __file__ seems to become common use. We (Jörg and I) have seen it on this list first. It's really nice ... André -- by _ _ _ Dr. André Wobst / \ \ / ) wo...@us..., http://www.wobsta.de/ / _ \ \/\/ / PyX - High quality PostScript figures with Python & TeX (_/ \_)_/\_/ visit http://pyx.sourceforge.net/ |