# using TeX backend on windows version of matplotlib?

Hello all,

First of all, I would like to say thank you to the matplotlib
developers for implementing a nice hack that enables a free python
environment to rival the functionality and power of matlab.

My question is whether it is possible to use the TeX backend to render
fonts under the windows versions of matplotlib? I am interested
in mixing standard text with math text as labels on plots. The
standard matplotlib font backend can almost do this, but it is not
robust, is hard to work with, and the results don’t look very
professional. On the contrary, the TeX backend is clean and
conformant (but it only appears to work on UNIX systems with TeX
installed). For example, this code

import pylab
pylab.rc(‘text’, usetex=True)
pylab.xlabel(r’normal text ($\alpha$)’)
pylab.plot(range(0,5))
pylab.show()

will not work on the windows version of matplotlib, but produces
beatiful labels on the linux version. FYI, the above “rc” command
is what requests the TeX backend rather than the default.

Thanks for your thoughts, ideas, and candor.

Mike Gilbert

Not really an answer to your question, but:
it looks like a parse error on the parentheses.
Put them inside the math delimiters and it works.

Cheers,
Alan Isaac

···

On Wed, 5 Oct 2005, Michael Gilbert apparently wrote:

import pylab
pylab.rc('text', usetex=True)
pylab.xlabel(r'normal text ($\alpha$)')
pylab.plot(range(0,5))
pylab.show()
will not work on the windows version of matplotlib,

Michael Gilbert wrote:

Hello all,

First of all, I would like to say thank you to the matplotlib developers
for implementing a nice hack that enables a free python environment to
rival the functionality and power of matlab.

My question is whether it is possible to use the TeX backend to render
fonts under the windows versions of matplotlib?

Probably. Do you have TeX installed on your Windows machine?

···

--
Robert Kern
rkern@...376...

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter

Hi Michael,
Your example works fine on my Win2k + MiKTeX setup with Matplotlib 0.83
Perhaps you should try deleting the contents of the .matplotlib cache directory. If this doesn't work, what version of Windows & Matplotlib are you running and are you using the MiKTeX distribution?
Gary R.

Michael Gilbert wrote:

···

Hello all,

First of all, I would like to say thank you to the matplotlib developers for implementing a nice hack that enables a free python environment to rival the functionality and power of matlab.

My question is whether it is possible to use the TeX backend to render fonts under the windows versions of matplotlib? I am interested in mixing standard text with math text as labels on plots. The standard matplotlib font backend can almost do this, but it is not robust, is hard to work with, and the results don't look very professional. On the contrary, the TeX backend is clean and conformant (but it only appears to work on UNIX systems with TeX installed). For example, this code

import pylab
pylab.rc('text', usetex=True)
pylab.xlabel(r'normal text ($\alpha$)')
pylab.plot(range(0,5))
pylab.show()

will not work on the windows version of matplotlib, but produces beatiful labels on the linux version. FYI, the above "rc" command is what requests the TeX backend rather than the default.

Thanks for your thoughts, ideas, and candor.

Mike Gilbert

You see the \alpha in his example??
Alan Isaac
Using Win2K + MiKTeX + Matplotlib 0.83.2

Cheers,
Alan Isaac

···

On Thu, 06 Oct 2005, Gary Ruben apparently wrote:

Your example works fine on my Win2k + MiKTeX setup with Matplotlib 0.83

Oops. Too hair trigger on the send button.
Deleting the cache worked.
But why?
I saw the problem the first time I ran his example.
What exactly is being cached?

Thank you,
Alan Isaac

···

On Thu, 06 Oct 2005, Gary Ruben apparently wrote:

Your example works fine on my Win2k + MiKTeX setup with Matplotlib 0.83

On Thu, 6 Oct 2005, Alan G Isaac apparently wrote:

You see the \alpha in his example??
Alan Isaac
Using Win2K + MiKTeX + Matplotlib 0.83.2

Alan G Isaac wrote:

Your example works fine on my Win2k + MiKTeX setup with Matplotlib 0.83

You see the \alpha in his example?? Alan Isaac Using Win2K + MiKTeX + Matplotlib 0.83.2

Oops. Too hair trigger on the send button.
Deleting the cache worked.
But why?

I don't know, but I had noticed in the past that this sometimes makes a difference. Not that it explains anything, but I'd say that the cache mechanism could do with some improvement.
I think it seemed to me to be the font cache rather than the TeX cache which made the difference.

I will now relate, for the record, that if anyone is trying to get TeX support to work with Windows 98, they will be unsuccessful for the following reasons:
There is a problem with MPL's TeX and PS support under Windows 98 where Win98 generates resource errors. This is related to Win98's awful pipes support; popen2 and popen3 calls basically do not work properly.
I have tried adding close() calls to the pipe input handle following each usage of a pipe. The idea is to force the pipes to be flushed. This improves the situation, although it does not guarantee a 100% fix, since I think the close() call requests that Windows flush and destroy the pipes but this can take an indeterminate time to act on. I don't know of a better way of doing this like any method of checking that a pipe has finished all its I/O activities.
One day I may try changing the os.popen calls to os.spawnl instead, since this approach should work.
The other small problem is something I suggested in a previous post (dated July 10th) which was not implemented, to do with Win98 returning "DVIPNG.EXE" instead of "dvipng" in response to
running "dvipng --version".
The fix here is to change the line:
if line.startswith('dvipng '):
to
if line.lower().startswith('dvipng'):

For now, I'll just use my Win2k machine.

Gary

···

On Thu, 06 Oct 2005, Gary Ruben apparently wrote:

On Thu, 6 Oct 2005, Alan G Isaac apparently wrote: