tex -> png

I would like to use Matplotlib for automatically generating

    > reports in HTML. I would like to do this without having to
    > use latex first and the convert from there (it would be much
    > faster to make my own HTML directly and I don't need lots of
    > complicated features yet). Has anyone already done this who
    > is willing to share code with me?

    > One thing I need to do that would make this work really well
    > is to generate little PNG's of symbols and formulas to use
    > in line with text in the HTML (sort of how LaTeX2HTML
    > handles using \\theta in line. Is there a way to use the
    > TeX rendering system used on figures to make little PNG's
    > 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

Thanks again John. The newest texmanager.py worked great.

John Hunter wrote:

···

<gtg708j@…622…>http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=clickMatplotlib-users@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/matplotlib-users