## [PyX-user] latex text help

 [PyX-user] latex text help From: Francisco Borges - 2005-05-02 14:56:58 Attachments: hyperplane.py Hello, I have done several plots using pyx and always got latex math text without problems. I'm doing just a figure drawing and things are not working. Can anyone tell what is wrong here: (I've simplified the code to the text related parts, attached goes the full (incomplete) figure.) from pyx import * text.set(mode="latex") def vector(x1, y1, x2, y2, t, pos=0.5, distance=0.1,arrows=[deco.earrow.normal]): """Return a vector like path with a label""" c = canvas.canvas() textbox = text.text((1-pos)*x1 + pos*x2, (1-pos)*y1 + pos*y2, t, [text.halign.center, text.vshift.mathaxis]) c.insert(textbox) return c def projection(x,y, x1, y1, x2, y2, label="", labelpos=.5, distance=-.2, mod=True): c = canvas.canvas() [[ Snipped code ]] textbox = text.text((1-p)*mx1 + p*mx2, (1-p)*my1 + p*my2, label, [text.halign.center, text.vshift.mathaxis]) if distance > 0: textbox.linealign(-distance, y1 - y2, x2 - x1) else: textbox.linealign(distance, y2 - y1, x1 - x2) c.insert(textbox) return c c = canvas.canvas() c.stroke(vector(X, Y, Wx, Wy, r"$\vec w$", distance=-.2)) c.stroke(vector(X,Y, Xx, Xy, r"$\vec x$", pos=0.8, distance=-.2)) c.stroke(projection(X,Y, Wx, Wy, Xx, Xy, r"$\cos\theta\|x\|$")) c.writeEPSfile(__file__[:-3]) -- Francisco Borges Alfa Informatica - RuG 

 [PyX-user] latex text help From: Francisco Borges - 2005-05-02 14:56:58 Attachments: hyperplane.py Hello, I have done several plots using pyx and always got latex math text without problems. I'm doing just a figure drawing and things are not working. Can anyone tell what is wrong here: (I've simplified the code to the text related parts, attached goes the full (incomplete) figure.) from pyx import * text.set(mode="latex") def vector(x1, y1, x2, y2, t, pos=0.5, distance=0.1,arrows=[deco.earrow.normal]): """Return a vector like path with a label""" c = canvas.canvas() textbox = text.text((1-pos)*x1 + pos*x2, (1-pos)*y1 + pos*y2, t, [text.halign.center, text.vshift.mathaxis]) c.insert(textbox) return c def projection(x,y, x1, y1, x2, y2, label="", labelpos=.5, distance=-.2, mod=True): c = canvas.canvas() [[ Snipped code ]] textbox = text.text((1-p)*mx1 + p*mx2, (1-p)*my1 + p*my2, label, [text.halign.center, text.vshift.mathaxis]) if distance > 0: textbox.linealign(-distance, y1 - y2, x2 - x1) else: textbox.linealign(distance, y2 - y1, x1 - x2) c.insert(textbox) return c c = canvas.canvas() c.stroke(vector(X, Y, Wx, Wy, r"$\vec w$", distance=-.2)) c.stroke(vector(X,Y, Xx, Xy, r"$\vec x$", pos=0.8, distance=-.2)) c.stroke(projection(X,Y, Wx, Wy, Xx, Xy, r"$\cos\theta\|x\|$")) c.writeEPSfile(__file__[:-3]) -- Francisco Borges Alfa Informatica - RuG 
 Re: [PyX-user] latex text help From: Joerg Lehmann - 2005-05-02 18:41:34 Hello Francisco, On 02.05.05, Francisco Borges wrote: > I have done several plots using pyx and always got latex math text > without problems. I'm doing just a figure drawing and things are not > working. > > Can anyone tell what is wrong here: > > (I've simplified the code to the text related parts, attached goes the > full (incomplete) figure.) > > from pyx import * > text.set(mode="latex") > > def vector(x1, y1, x2, y2, t, pos=0.5, distance=0.1,arrows=[deco.earrow.normal]): > """Return a vector like path with a label""" > c = canvas.canvas() > textbox = text.text((1-pos)*x1 + pos*x2, (1-pos)*y1 + pos*y2, t, > [text.halign.center, text.vshift.mathaxis]) > c.insert(textbox) > return c Here you return a canvas. [...] > c = canvas.canvas() > c.stroke(vector(X, Y, Wx, Wy, r"$\vec w$", distance=-.2)) An here you stroke it, which doesn't work. Use: c.insert(vector(X, Y, Wx, Wy, r"$\vec w$", distance=-.2)) instead. Jörg