163 lines (130 with data), 10.2 kB
@header@
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="matplotlib.html"><font color="#ffffff">matplotlib</font></a>.texmanager</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/jdhunter/dev/lib64/python2.5/site-packages/matplotlib/texmanager.py">/home/jdhunter/dev/lib64/python2.5/site-packages/matplotlib/texmanager.py</a></font></td></tr></table>
<p><tt>This module supports embedded TeX expressions in matplotlib via dvipng<br>
and dvips for the raster and postscript backends. The tex and<br>
dvipng/dvips information is cached in ~/.matplotlib/tex.cache for reuse between<br>
sessions<br>
<br>
Requirements:<br>
<br>
* latex<br>
* \*Agg backends: dvipng<br>
* PS backend: latex w/ psfrag, dvips, and Ghostscript 8.51<br>
(older versions do not work properly)<br>
<br>
Backends:<br>
<br>
* \*Agg<br>
* PS<br>
* PDF<br>
<br>
For raster output, you can get RGBA numpy arrays from TeX expressions<br>
as follows::<br>
<br>
texmanager = <a href="#TexManager">TexManager</a>()<br>
s = '\TeX\ is Number $\displaystyle\sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}$!'<br>
Z = self.<strong>texmanager</strong>.get_rgba(s, size=12, dpi=80, rgb=(1,0,0))<br>
<br>
To enable tex rendering of all text in your matplotlib figure, set<br>
text.usetex in your matplotlibrc file (<a href="http://matplotlib.sf.net/matplotlibrc">http://matplotlib.sf.net/matplotlibrc</a>)<br>
or include these two lines in your script::<br>
<br>
from matplotlib import rc<br>
rc('text', usetex=True)</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom> <br>
<font color="#fffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="copy.html">copy</a><br>
<a href="distutils.html">distutils</a><br>
<a href="glob.html">glob</a><br>
</td><td width="25%" valign=top><a href="matplotlib.html">matplotlib</a><br>
<a href="numpy.html">numpy</a><br>
<a href="os.html">os</a><br>
</td><td width="25%" valign=top><a href="shutil.html">shutil</a><br>
<a href="sys.html">sys</a><br>
<a href="warnings.html">warnings</a><br>
</td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="matplotlib.texmanager.html#TexManager">TexManager</a>
</font></dt></dl>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="TexManager">class <strong>TexManager</strong></a></font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Convert strings to dvi files using TeX, caching the results to a<br>
working dir<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="TexManager-__init__"><strong>__init__</strong></a>(self)</dt></dl>
<dl><dt><a name="TexManager-get_basefile"><strong>get_basefile</strong></a>(self, tex, fontsize, dpi<font color="#909090">=None</font>)</dt><dd><tt>returns a filename based on a hash of the string, fontsize, and dpi</tt></dd></dl>
<dl><dt><a name="TexManager-get_custom_preamble"><strong>get_custom_preamble</strong></a>(self)</dt><dd><tt>returns a string containing user additions to the tex preamble</tt></dd></dl>
<dl><dt><a name="TexManager-get_font_config"><strong>get_font_config</strong></a>(self)</dt><dd><tt>Reinitializes self if relevant rcParams on have changed.</tt></dd></dl>
<dl><dt><a name="TexManager-get_font_preamble"><strong>get_font_preamble</strong></a>(self)</dt><dd><tt>returns a string containing font configuration for the tex preamble</tt></dd></dl>
<dl><dt><a name="TexManager-get_grey"><strong>get_grey</strong></a>(self, tex, fontsize<font color="#909090">=None</font>, dpi<font color="#909090">=None</font>)</dt><dd><tt>returns the alpha channel</tt></dd></dl>
<dl><dt><a name="TexManager-get_ps_bbox"><strong>get_ps_bbox</strong></a>(self, tex, fontsize)</dt><dd><tt>returns a list containing the postscript bounding box for latex's<br>
rendering of the tex string</tt></dd></dl>
<dl><dt><a name="TexManager-get_rgba"><strong>get_rgba</strong></a>(self, tex, fontsize<font color="#909090">=None</font>, dpi<font color="#909090">=None</font>, rgb<font color="#909090">=(0, 0, 0)</font>)</dt><dd><tt>Returns latex's rendering of the tex string as an rgba array</tt></dd></dl>
<dl><dt><a name="TexManager-make_dvi"><strong>make_dvi</strong></a>(self, tex, fontsize)</dt><dd><tt>generates a dvi file containing latex's layout of tex string<br>
<br>
returns the file name</tt></dd></dl>
<dl><dt><a name="TexManager-make_png"><strong>make_png</strong></a>(self, tex, fontsize, dpi)</dt><dd><tt>generates a png file containing latex's rendering of tex string<br>
<br>
returns the filename</tt></dd></dl>
<dl><dt><a name="TexManager-make_ps"><strong>make_ps</strong></a>(self, tex, fontsize)</dt><dd><tt>generates a postscript file containing latex's rendering of tex string<br>
<br>
returns the file name</tt></dd></dl>
<dl><dt><a name="TexManager-make_tex"><strong>make_tex</strong></a>(self, tex, fontsize)</dt><dd><tt>Generate a tex file to render the tex string at a specific font size<br>
<br>
returns the file name</tt></dd></dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>configdir</strong> = '/home/jdhunter/.matplotlib'</dl>
<dl><dt><strong>cursive</strong> = ('pzc', r'\usepackage{chancery}')</dl>
<dl><dt><strong>font_families</strong> = ('serif', 'sans-serif', 'cursive', 'monospace')</dl>
<dl><dt><strong>font_family</strong> = 'serif'</dl>
<dl><dt><strong>font_info</strong> = {'avant garde': ('pag', r'\usepackage{avant}'), 'bookman': ('pbk', r'\renewcommand{\rmdefault}{pbk}'), 'charter': ('pch', r'\usepackage{charter}'), 'computer modern roman': ('cmr', ''), 'computer modern sans serif': ('cmss', ''), 'computer modern typewriter': ('cmtt', ''), 'courier': ('pcr', r'\usepackage{courier}'), 'cursive': ('pzc', r'\usepackage{chancery}'), 'helvetica': ('phv', r'\usepackage{helvet}'), 'monospace': ('cmtt', ''), ...}</dl>
<dl><dt><strong>grey_arrayd</strong> = {}</dl>
<dl><dt><strong>monospace</strong> = ('cmtt', '')</dl>
<dl><dt><strong>n</strong> = 'monospace'</dl>
<dl><dt><strong>oldcache</strong> = '/home/jdhunter/.tex.cache'</dl>
<dl><dt><strong>oldpath</strong> = '/home/jdhunter'</dl>
<dl><dt><strong>postscriptd</strong> = {}</dl>
<dl><dt><strong>pscnt</strong> = 0</dl>
<dl><dt><strong>rgba_arrayd</strong> = {}</dl>
<dl><dt><strong>sans_serif</strong> = ('cmss', '')</dl>
<dl><dt><strong>serif</strong> = ('cmr', '')</dl>
<dl><dt><strong>texcache</strong> = '/home/jdhunter/.matplotlib/tex.cache'</dl>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt><a name="-dvipng_hack_alpha"><strong>dvipng_hack_alpha</strong></a>()</dt></dl>
<dl><dt><a name="-md5"><strong>md5</strong></a> = openssl_md5(...)</dt><dd><tt>Returns a md5 hash object; optionally initialized with a string</tt></dd></dl>
<dl><dt><a name="-read_png"><strong>read_png</strong></a>(...)</dt><dd><tt><a href="#-read_png">read_png</a>(fileobj)</tt></dd></dl>
</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
<td width="100%"><strong>DEBUG</strong> = False<br>
<strong>cmd_split</strong> = ';'<br>
<strong>rcParams</strong> = {'figure.subplot.right': 0.90000000000000002, 'm...persize': 'letter', 'svg.embed_char_paths': True}</td></tr></table>
@footer@