Rehello,
On 12.05.09, Giorgos Logiotatidis wrote:
> I use pyx library to hack a python parser of a network map. I based my
> work on this [1] example. I 'm searching for a way to label the arcs
> connecting the nodes but I haven't managed to find anything since it's
> the first time I use pyx and looks really complicated. Does anyone know
> a way to do this?
There is a path decorator, ready-made for this purpose. It is called
deco.text. Look at the following example, which accounts for the
proper angle of the path at the point where the label is attached:
from pyx import *
from math import atan2, degrees
p = path.curve(0, 0, 1, 1, 2, 0, 4, 0)
x, y = p.at(0.5*p.arclen())
angle = degrees(atan2(*p.trafo(0.5*p.arclen()).apply_pt(0,1)))
c = canvas.canvas()
c.stroke(path.circle(x, y, 0.01))
c.stroke(p, [deco.text("label", textattrs=[text.halign.left], textdist=0.2,
angle=angle)])
c.writePDFfile("foo")
Michael
------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
PyX-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyx-user