# tex -> png

···

Thanks for the quick and
helpful response John. I seem to more or less
up and running. Two things though. The first time I run the commands
in your e-mail I get an error, but the files seems to be created
correctly.

In [7]: m = TexManager()

In [8]: pngfile = m.make_png("\TeX\ is Number $e^{-i\pi}$!", dpi=100)

This is TeX, Version 3.14159 (Web2C 7.4.5)

(/home/ryan/.tex.cache/5b723d2ea8d0f15af94ec585aece1582.tex [1] )

Output written on 5b723d2ea8d0f15af94ec585aece1582.dvi (1 page, 384
bytes).

Transcript written on 5b723d2ea8d0f15af94ec585aece1582.log.

[1]

exceptions.SystemExit Traceback (most
recent call last)

/home/ryan/research/varying_amp_05_09_05/

/usr/lib/python2.3/site-packages/matplotlib/texmanager.py in
make_png(self, tex, dpi, force)

 69         if force or not os.path.exists(pngfile):

70             os.system(command)


—> 71 raise SystemExit

 72         return pngfile

73


SystemExit:

Use Ctrl-D (i.e. EOF) to exit. Use %Exit or %Quit to exit without
confirmation.

In [9]: pngfile = m.make_png("\TeX\ is Number $e^{-i\pi}$!", dpi=100)

In [10]:

Looking at the code, it seems like SystemExit is raised any time the

I am running these lines inside ipython, if that matters. Something
about my system doesn’t like the SystemExit being raised.

My second question is this. I am running Linux here at home and the
install of dvipng went really smooth. Is there a windows port of
dvipng? I may need to use windows at school.

Thanks,

Ryan

John Hunter wrote:

"Ryan" == Ryan Krauss writes:

    Ryan> I would like to use Matplotlib for automatically generating
Ryan> reports in HTML. I would like to do this without having to
Ryan> use latex first and the convert from there (it would be much
Ryan> faster to make my own HTML directly and I don't need lots of
Ryan> complicated features yet). Has anyone already done this who
Ryan> is willing to share code with me?
Ryan> One thing I need to do that would make this work really well
Ryan> is to generate little PNG's of symbols and formulas to use
Ryan> in line with text in the HTML (sort of how LaTeX2HTML
Ryan> handles using $\theta$ in line. Is there a way to use the
Ryan> TeX rendering system used on figures to make little PNG's
Ryan> with just TeX expressions on them (i.e. theta.png)?
TeX/LaTeX plus dvipng is really the right way to solve this problem.
Coincidentally, I have been working to incorporate tex into
backend_agg via dvipng (and into backend_ps via psfrag) and matplotlib
has a tex manager class
So if you don't mind installing tex and dvipng (on my Ubuntu system is
is simply > sudo apt-get install dvipng
then you can use the matplotlib texmanager class to handle the system
calls, cacheing results it's seen before and so on
>>> from matplotlib.texmanager import TexManager
>>> m = TexManager()
>>> pngfile = m.make_png("\TeX\ is Number $e^{-i\pi}$!", dpi=100)
>>> print pngfile
/home/jdhunter/.tex.cache/5b723d2ea8d0f15af94ec585aece1582_100.png
You need to make sure you have texmanager revision 1.2 from CVS (or
later). Of course if you are on a platform where TeX is not easily installed,
this won't help much. In that case, you can use matplotlib to create
the math images for you, but I would use the mathtext parser directly
rather than the whole figure / axes api.
Let me know if you still want/need to use mpl for this and I'll give
you some pointers.
JDH
-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes
Want to be the first software developer in space?
Enter now for the Oracle Space Sweepstakes!
_______________________________________________
Matplotlib-users mailing list


Ryan Krauss wrote:

Looking at the code, it seems like SystemExit is raised any time the png doesn't already exist.
I am running these lines inside ipython, if that matters. Something about my system doesn't like the SystemExit being raised.

yes, it's an annoyance of ipython whenever you run anything with a SystemExit in it. The .14 release of ipython has a new -e switch to ignore exit calls, so you don't get all that noise (use 'run -e fooscript').

If you feel adventurous, I put yesterday a release candidate here:

http://ipython.scipy.org/dist/testing/

Let me know of any problems you encounter though, I'd like this to really fix all known glitches for a while so I can concentrate only on new development.

Best,

f