Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project!

## [PyX-user] LaTeX Labels

 [PyX-user] LaTeX Labels From: Dan Reinholz - 2008-07-17 22:36:57 I'm having a bit of trouble labeling some graphs of mine. The first one is: from pyx import * from pyx.graph import axis g = graph.graphxy(width=8, x=axis.linear(min=1, max=10, title="$\tau$"), y=axis.linear(title="$R(\sqrt{0.5\tau})$")) g.plot(graph.data.function("y(x)= sqrt(0.5*x)/((sqrt(0.5*x) +0.5)*(sqrt(0.5*x)+x))",points=500)) g.finish() g.writeEPSfile("derivatives_opt_1") The problem is that rather than showing the Greek letter tau the output is 5au. My understanding was I could just use LaTeX labels directly, but perhaps I'm doing something wrong? The second is a similar problem. I have another graph: from pyx import * from pyx.graph import axis g = graph.graphxy(width=8, x=axis.linear(min=1, max=10, title="$\tau$"), y=axis.linear(title="$\frac{\sqrt{0.5\tau}}{\sqrt{0.5\tau}+\tau}$")) g.plot(graph.data.function("y(x)=sqrt(0.5*x)/(sqrt(0.5*x)+x)",points=500)) g.finish() g.writeEPSfile("derivatives_opt_2") where here I actually want use a fraction in the label. Trying to do so python becomes very unhappy with me bsd% python derivatives_opt_2.py Traceback (most recent call last): File "derivatives_opt_2.py", line 10, in g.finish() File "/usr/local/lib/python2.5/site-packages/pyx/graph/graph.py", line 268, in finish self.doaxes() File "/usr/local/lib/python2.5/site-packages/pyx/graph/graph.py", line 491, in doaxes self.dolayout() File "/usr/local/lib/python2.5/site-packages/pyx/graph/graph.py", line 475, in dolayout self.doaxiscreate(axisname) File "/usr/local/lib/python2.5/site-packages/pyx/graph/graph.py", line 216, in doaxiscreate self.axes[axisname].create() File "/usr/local/lib/python2.5/site-packages/pyx/graph/axis/axis.py", line 565, in create self.canvas = self.axis.create(self.data, self.positioner, self.graphtexrunner, self.errorname) File "/usr/local/lib/python2.5/site-packages/pyx/graph/axis/axis.py", line 228, in create return _regularaxis._create(self, data, positioner, graphtexrunner, self.parter, self.rater, errorname) File "/usr/local/lib/python2.5/site-packages/pyx/graph/axis/axis.py", line 198, in _create variants[0].storedcanvas = layout(variants[0]) File "/usr/local/lib/python2.5/site-packages/pyx/graph/axis/axis.py", line 133, in layout self.painter.paint(canvas, data, self, positioner) File "/usr/local/lib/python2.5/site-packages/pyx/graph/axis/painter.py", line 253, in paint _title.paint(self, canvas, data, axis, axispos) File "/usr/local/lib/python2.5/site-packages/pyx/graph/axis/painter.py", line 104, in paint title = canvas.text_pt(x, y, axis.title, titleattrs) File "/usr/local/lib/python2.5/site-packages/pyx/canvas.py", line 319, in text_pt return self.insert(self.texrunner.text_pt(x, y, atext, *args)) File "/usr/local/lib/python2.5/site-packages/pyx/text.py", line 1222, in text_pt return self.text(x * unit.t_pt, y * unit.t_pt, expr, *args, **kwargs) File "/usr/local/lib/python2.5/site-packages/pyx/text.py", line 1201, in text self.finishdvi(ignoretail=1) File "/usr/local/lib/python2.5/site-packages/pyx/text.py", line 1044, in finishdvi self.execute(None, self.defaulttexmessagesend + self.texmessagesend) File "/usr/local/lib/python2.5/site-packages/pyx/text.py", line 1036, in execute raise TexResultError("unhandled TeX response (might be an error)", self) pyx.text.TexResultError: unhandled TeX response (might be an error) The expression passed to TeX was: \end% After parsing the return message from TeX, the following was left: *[1] Am I doing something wrong here, or is it just not possible to create labels using fractions? All help is greatly appreciated as always. Thanks, -Daniel 

### Thread view

 [PyX-user] LaTeX Labels From: Dan Reinholz - 2008-07-17 22:36:57 I'm having a bit of trouble labeling some graphs of mine. The first one is: from pyx import * from pyx.graph import axis g = graph.graphxy(width=8, x=axis.linear(min=1, max=10, title="$\tau$"), y=axis.linear(title="$R(\sqrt{0.5\tau})$")) g.plot(graph.data.function("y(x)= sqrt(0.5*x)/((sqrt(0.5*x) +0.5)*(sqrt(0.5*x)+x))",points=500)) g.finish() g.writeEPSfile("derivatives_opt_1") The problem is that rather than showing the Greek letter tau the output is 5au. My understanding was I could just use LaTeX labels directly, but perhaps I'm doing something wrong? The second is a similar problem. I have another graph: from pyx import * from pyx.graph import axis g = graph.graphxy(width=8, x=axis.linear(min=1, max=10, title="$\tau$"), y=axis.linear(title="$\frac{\sqrt{0.5\tau}}{\sqrt{0.5\tau}+\tau}$")) g.plot(graph.data.function("y(x)=sqrt(0.5*x)/(sqrt(0.5*x)+x)",points=500)) g.finish() g.writeEPSfile("derivatives_opt_2") where here I actually want use a fraction in the label. Trying to do so python becomes very unhappy with me bsd% python derivatives_opt_2.py Traceback (most recent call last): File "derivatives_opt_2.py", line 10, in g.finish() File "/usr/local/lib/python2.5/site-packages/pyx/graph/graph.py", line 268, in finish self.doaxes() File "/usr/local/lib/python2.5/site-packages/pyx/graph/graph.py", line 491, in doaxes self.dolayout() File "/usr/local/lib/python2.5/site-packages/pyx/graph/graph.py", line 475, in dolayout self.doaxiscreate(axisname) File "/usr/local/lib/python2.5/site-packages/pyx/graph/graph.py", line 216, in doaxiscreate self.axes[axisname].create() File "/usr/local/lib/python2.5/site-packages/pyx/graph/axis/axis.py", line 565, in create self.canvas = self.axis.create(self.data, self.positioner, self.graphtexrunner, self.errorname) File "/usr/local/lib/python2.5/site-packages/pyx/graph/axis/axis.py", line 228, in create return _regularaxis._create(self, data, positioner, graphtexrunner, self.parter, self.rater, errorname) File "/usr/local/lib/python2.5/site-packages/pyx/graph/axis/axis.py", line 198, in _create variants[0].storedcanvas = layout(variants[0]) File "/usr/local/lib/python2.5/site-packages/pyx/graph/axis/axis.py", line 133, in layout self.painter.paint(canvas, data, self, positioner) File "/usr/local/lib/python2.5/site-packages/pyx/graph/axis/painter.py", line 253, in paint _title.paint(self, canvas, data, axis, axispos) File "/usr/local/lib/python2.5/site-packages/pyx/graph/axis/painter.py", line 104, in paint title = canvas.text_pt(x, y, axis.title, titleattrs) File "/usr/local/lib/python2.5/site-packages/pyx/canvas.py", line 319, in text_pt return self.insert(self.texrunner.text_pt(x, y, atext, *args)) File "/usr/local/lib/python2.5/site-packages/pyx/text.py", line 1222, in text_pt return self.text(x * unit.t_pt, y * unit.t_pt, expr, *args, **kwargs) File "/usr/local/lib/python2.5/site-packages/pyx/text.py", line 1201, in text self.finishdvi(ignoretail=1) File "/usr/local/lib/python2.5/site-packages/pyx/text.py", line 1044, in finishdvi self.execute(None, self.defaulttexmessagesend + self.texmessagesend) File "/usr/local/lib/python2.5/site-packages/pyx/text.py", line 1036, in execute raise TexResultError("unhandled TeX response (might be an error)", self) pyx.text.TexResultError: unhandled TeX response (might be an error) The expression passed to TeX was: \end% After parsing the return message from TeX, the following was left: *[1] Am I doing something wrong here, or is it just not possible to create labels using fractions? All help is greatly appreciated as always. Thanks, -Daniel 
 Re: [PyX-user] LaTeX Labels From: Alan G Isaac - 2008-07-17 22:55:34 On Thu, 17 Jul 2008, Dan Reinholz apparently wrote: > title="$\tau$" Use raw strings: http://docs.python.org/tut/node5.html#SECTION005120000000000000000 Cheers, Alan Isaac