From: Andre W. <wo...@us...> - 2005-11-01 11:56:25
|
Hi, On 01.11.05, Arnd Baecker wrote: > when plotting with symbols, part of the symbol > may be outside of the plot region. > Is there a simple way to clip any those parts away? > > (I tried to change the code so that > a graphxy can pass on `attrs` to the underlying canvas._canvas, > however the resulting clipping was so effective, that > even the labels were clipped away.) You need to modify attributes of the canvas where the symbols are drawn to. This is quite simple: from pyx import * class clipsymbol(graph.style.symbol): def initdrawpoints(self, privatedata, sharedata, graph): privatedata.symbolcanvas = canvas.canvas([canvas.clip(path.rect_pt(graph.xpos_pt, graph.ypos_pt, graph.width_pt, graph.height_pt))]) g = graph.graphxy(width=8) g.plot(graph.data.file("minimal.dat", x=1, y=2), [clipsymbol()]) g.writeEPSfile("minimal") In general I think such a clipping is a bad idea (feel free to argue against this). So for the moment I would not like to add such a feature to the symbol style directly (although we could do, but as usual: "bad ideas won't be implemented" ... ;-)). André -- by _ _ _ Dr. André Wobst / \ \ / ) wo...@us..., http://www.wobsta.de/ / _ \ \/\/ / PyX - High quality PostScript and PDF figures (_/ \_)_/\_/ with Python & TeX: visit http://pyx.sourceforge.net/ |