Re: [Matplotlib-users] Displaying \frac{a}{b} in xlabel From: John Hunter - 2006-03-08 17:17 >>>>> "Darren" == Darren Dale writes: Darren> Thank you for the suggestion. How is it compatible with Darren> Python-2.3? Do you mean we would include the source for Darren> that module in mpl? Yep, just as we include pyparsing, et al. JDH 

[Matplotlib-users] Displaying \frac{a}{b} in xlabel Nils Wagner <nwagner@me...>
 Re: [Matplotlib-users] Displaying \frac{a}{b} in xlabel From: Christian Meesters - 2006-03-08 12:22 Hoi, On Wednesday 08 March 2006 11:06, Nils Wagner wrote: > title(r'\frac{\Theta}{2\pi}') > xlabel(r'\frac{\Theta}{2\pi}') # The output is not o.k. And the writing the title is working? Try xlabel(r'$\frac{\Theta}{2\pi}$') instead. Hope this helps. Christian 

 Re: [Matplotlib-users] Displaying \frac{a}{b} in xlabel From: Darren Dale - 2006-03-08 12:28 >> On Wednesday 08 March 2006 5:06 am, Nils Wagner wrote: >> =A0=20 >>> Hi all, >>> >>> How do I use \frac{a}{b} within labels ? >>> >>> from pylab import * >>> from scipy import * >>> x =3D linspace(0,pi,20) >>> plot(x,sin(x)) >>> title(r'\frac{\Theta}{2\pi}') >>> xlabel(r'\frac{\Theta}{2\pi}') =A0# The output is not o.k. >>> show() >>> >>> Am I missing something or is it a bug ? >>> =A0 =A0=20 >> >> What does "The output is not o.k." mean? >> =A0=20 > The output is somewhat like \Theta \frac{}{2\pi} > If I use > xlabel(r'$\frac{\Theta}{2\pi}$') > > it works fine. This is not a bug. Please keep in mind that usetex is really only an interf= ace=20 to latex. For problems specific to LaTeX, it would be best to consult the=20 appropriate sources or lists. As it happens, \frac is only allowed in math= =20 mode. That it produced any output at outside of mathmode is a case of faili= ng=20 silently. Does anyone know how to catch exit status using os.popen and friends? LaTeX= =20 would have returned an exit status of 1 for this example, which could be us= ed=20 to raise a warning. Darren 

 [Matplotlib-users] Re: Displaying \frac{a}{b} in xlabel From: Jouni K Seppanen - 2006-03-08 13:42 Darren Dale writes: > Does anyone know how to catch exit status using os.popen and > friends? LaTeX would have returned an exit status of 1 for this > example, which could be used to raise a warning. I think you should get the exit status from the close() method, and http://docs.python.org/lib/os-newstreams.html seems to confirm this. Strangely, popen2 etc do not allow you to get the exit status. -- Jouni 

 Re: [Matplotlib-users] Displaying \frac{a}{b} in xlabel From: Ryan Krauss - 2006-03-08 13:43 I think I got it. I had to play around a bit with a couple different approaches. Part of the trick is that you have to run latex with -interaction=3Dnonstopmode, otherwise the child process never completes and it seems like most of python's tools for capturing the errors and outputs just hang. Here is what I did: import popen2 In [8]: latexcmd3=3Dpopen2.Popen3('latex -interaction=3Dnonstopmode bad.tex= ') In [9]: latexcmd3.wait() Out[9]: 256 In [10]: latexcmd4=3Dpopen2.Popen3('latex -interaction=3Dnonstopmode good.t= ex') In [11]: latexcmd4.wait() Out[11]: 0 where bad.tex and good.tex basically have just headers and \frac{1}{\theta} with and without  around it. If I just use os.popen3, the stderr object returned is empty in both cases: In [14]: r,w,e=3Dos.popen3('latex -interaction=3Dnonstopmode good.tex') In [15]: e.readlines() Out[15]: [] In [16]: r,w,e=3Dos.popen3('latex -interaction=3Dnonstopmode bad.tex') In [17]: e.readlines() Out[17]: [] and to know there was a problem, you would have to parse w.readlines() - and in this case it doesn't even say there is an error, it mentions something about a missing $. But it seems like creating your own Popen3 object and executing it through the wait() command, returns 0 on a clean exit or 256 on the bad ones (at least for this error). I have compiled one other good file from my hard drive and it also returns 0. Hope this helps, Ryan On 3/8/06, Darren Dale wrote: > >> On Wednesday 08 March 2006 5:06 am, Nils Wagner wrote: > >> > >>> Hi all, > >>> > >>> How do I use \frac{a}{b} within labels ? > >>> > >>> from pylab import * > >>> from scipy import * > >>> x =3D linspace(0,pi,20) > >>> plot(x,sin(x)) > >>> title(r'\frac{\Theta}{2\pi}') > >>> xlabel(r'\frac{\Theta}{2\pi}') # The output is not o.k. > >>> show() > >>> > >>> Am I missing something or is it a bug ? > >>> > >> > >> What does "The output is not o.k." mean? > >> > > The output is somewhat like \Theta \frac{}{2\pi} > > If I use > > xlabel(r'$\frac{\Theta}{2\pi}$') > > > > it works fine. > > This is not a bug. Please keep in mind that usetex is really only an inte= rface > to latex. For problems specific to LaTeX, it would be best to consult the > appropriate sources or lists. As it happens, \frac is only allowed in mat= h > mode. That it produced any output at outside of mathmode is a case of fai= ling > silently. > > Does anyone know how to catch exit status using os.popen and friends? LaT= eX > would have returned an exit status of 1 for this example, which could be = used > to raise a warning. > > Darren > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting langua= ge > that extends applications into web and mobile media. Attend the live webc= ast > and join the prime developer group breaking into this new coding territor= y! > http://sel.as-us.falkag.net/sel?cmdlnk&kid=110944&bid$1720&dat=121642 > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > 

 Re: [Matplotlib-users] Displaying \frac{a}{b} in xlabel From: Andrew Straw - 2006-03-08 17:07 Hi Darren, >Does anyone know how to catch exit status using os.popen and friends? > You may want to switch to subprocess.py. It comes with Python 2.4, but it's backwards compatible with Python2.3 (maybe older). We could just include it alongside the modules that want to use it. It's pretty easy to use and is meant to unify all the various ways of executing a subprocess. Here's an example from some other code of mine (a recursive build tool that seeks out directories with setup.py and builds them with setuptools). It should be a good example of using subprocess. args = [sys.executable,'-c',"import setuptools; execfile('setup.py')"] args.extend(commands) print dir,':',' '.join(args) sub = subprocess.Popen(args, cwd=dir, stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) sub.wait() if sub.returncode != 0: print '-='*20 print '*** The following call failed:' print args stdout = sub.stdout.read() if len(stdout): print '*** stdout was:' print stdout stderr = sub.stderr.read() if len(stderr): print '*** stderr was:' print stderr print '-='*20 sys.exit( sub.returncode ) 

 Re: [Matplotlib-users] Displaying \frac{a}{b} in xlabel From: Darren Dale - 2006-03-08 17:15 On Wednesday 08 March 2006 12:07, you wrote: > Hi Darren, > > >Does anyone know how to catch exit status using os.popen and friends? > > You may want to switch to subprocess.py. It comes with Python 2.4, but > it's backwards compatible with Python2.3 (maybe older). Thank you for the suggestion. How is it compatible with Python-2.3? Do you mean we would include the source for that module in mpl? 

 Re: [Matplotlib-users] Displaying \frac{a}{b} in xlabel From: John Hunter - 2006-03-08 17:17 >>>>> "Darren" == Darren Dale writes: Darren> Thank you for the suggestion. How is it compatible with Darren> Python-2.3? Do you mean we would include the source for Darren> that module in mpl? Yep, just as we include pyparsing, et al. JDH 

 Re: [Matplotlib-users] Displaying \frac{a}{b} in xlabel From: Andrew Straw - 2006-03-08 17:18 Darren Dale wrote: >On Wednesday 08 March 2006 12:07, you wrote: > > >>Hi Darren, >> >> >> >>>Does anyone know how to catch exit status using os.popen and friends? >>> >>> >>You may want to switch to subprocess.py. It comes with Python 2.4, but >>it's backwards compatible with Python2.3 (maybe older). >> >> > >Thank you for the suggestion. How is it compatible with Python-2.3? Do you >mean we would include the source for that module in mpl? > > Yes, exactly. 

 Re: [Matplotlib-users] Displaying \frac{a}{b} in xlabel From: Eric Firing - 2006-03-08 18:11 John, John Hunter wrote: >>>>>>"Darren" == Darren Dale writes: > > Darren> Thank you for the suggestion. How is it compatible with > Darren> Python-2.3? Do you mean we would include the source for > Darren> that module in mpl? > > Yep, just as we include pyparsing, et al. > > JDH What about Python-2.2? Do we still need to stay compatible with that? I would be happy to see that go, and officially move the requirement up to 2.3, if this has not already been done. Eric 

 Re: [Matplotlib-users] Displaying \frac{a}{b} in xlabel From: Darren Dale - 2006-03-08 20:53 On Wednesday 08 March 2006 13:10, Eric Firing wrote: > John, > > John Hunter wrote: > >>>>>>"Darren" == Darren Dale writes: > > > > Darren> Thank you for the suggestion. How is it compatible with > > Darren> Python-2.3? Do you mean we would include the source for > > Darren> that module in mpl? > > > > Yep, just as we include pyparsing, et al. > > > > JDH > > What about Python-2.2? Do we still need to stay compatible with that? > I would be happy to see that go, and officially move the requirement up > to 2.3, if this has not already been done. I have posted subprocess.py at http://staff.chess.cornell.edu/~dale/matplotlib/subprocess.py running python subprocess.py will execute a test, which I tried with python 2.2 and 2.3 on linux. They both seemed to work. A successful test includes failing to open a bogus file and therefore raising an exception as the last step. Would anyone running python-2.3 or 2.2 on windows or mac run this test and report the result? Thanks, Darren