@header@
matplotlib.mathtext | index /usr/lib/python2.4/site-packages/matplotlib/mathtext.py |
OVERVIEW
mathtext is a module for parsing TeX expressions and drawing them
into a matplotlib.ft2font image buffer. You can draw from this
buffer into your backend.
A large set of the TeX symbols are provided (see below).
Subscripting and superscripting are supported, as well as the
over/under style of subscripting with \sum, \int, etc.
The module uses pyparsing to parse the TeX expression, an so can
handle fairly complex TeX expressions Eg, the following renders
correctly
s = r'$\cal{R}\prod_{i=\alpha\cal{B}}^\infty a_i\rm{sin}(2 \pi f x_i)$'
The fonts \cal, \rm, \it, and \tt are allowed.
The following accents are provided: \hat, \breve, \grave, \bar,
\acute, \tilde, \vec, \dot, \ddot. All of them have the same
syntax, eg to make an overbar you do \bar{o} or to make an o umlaut
you do \ddot{o}. The shortcuts are also provided, eg: \"o \'e \`e
\~n \.x \^y
The spacing elements \ , \/ and \hspace{num} are provided. \/
inserts a small space, and \hspace{num} inserts a fraction of the
current fontsize. Eg, if num=0.5 and the fontsize is 12.0,
hspace{0.5} inserts 6 points of space
If you find TeX expressions that don't parse or render properly,
please email me, but please check KNOWN ISSUES below first.
REQUIREMENTS
mathtext requires matplotlib.ft2font. Set BUILD_FT2FONT=True in
setup.py. See BACKENDS below for a summary of availability by
backend.
LICENSING:
The computer modern fonts this package uses are part of the BaKoMa
fonts, which are (now) free for commercial and noncommercial use and
redistribution; see license/LICENSE_BAKOMA in the matplotlib src
distribution for redistribution requirements.
USAGE:
See http://matplotlib.sourceforge.net/tutorial.html#mathtext for a
tutorial introduction.
Any text element (xlabel, ylabel, title, text, etc) can use TeX
markup, as in
xlabel(r'$\Delta_i$')
^
use raw strings
The $ symbols must be the first and last symbols in the string. Eg,
you cannot do
r'My label $x_i$'.
but you can change fonts, as in
r'$\rm{My label} x_i$'
to achieve the same effect.
A large set of the TeX symbols are provided. Subscripting and
superscripting are supported, as well as the over/under style of
subscripting with \sum, \int, etc.
Allowed TeX symbols:
\/ \Delta \Downarrow \Gamma \Im \LEFTangle \LEFTbrace \LEFTbracket
\LEFTparen \Lambda \Leftarrow \Leftbrace \Leftbracket \Leftparen
\Leftrightarrow \Omega \P \Phi \Pi \Psi \RIGHTangle \RIGHTbrace
\RIGHTbracket \RIGHTparen \Re \Rightarrow \Rightbrace \Rightbracket
\Rightparen \S \SQRT \Sigma \Sqrt \Theta \Uparrow \Updownarrow
\Upsilon \Vert \Xi \aleph \alpha \approx \angstrom \ast \asymp
\backslash \beta \bigcap \bigcirc \bigcup \bigodot \bigoplus
\bigotimes \bigtriangledown \bigtriangleup \biguplus \bigvee
\bigwedge \bot \bullet \cap \cdot \chi \circ \clubsuit \coprod \cup
\dag \dashv \ddag \delta \diamond \diamondsuit \div \downarrow \ell
\emptyset \epsilon \equiv \eta \exists \flat \forall \frown \gamma
\geq \gg \heartsuit \hspace \imath \in \infty \int \iota \jmath
\kappa \lambda \langle \lbrace \lceil \leftangle \leftarrow
\leftbrace \leftbracket \leftharpoondown \leftharpoonup \leftparen
\leftrightarrow \leq \lfloor \ll \mid \mp \mu \nabla \natural
\nearrow \neg \ni \nu \nwarrow \odot \oint \omega \ominus \oplus
\oslash \otimes \phi \pi \pm \prec \preceq \prime \prod \propto \psi
\rangle \rbrace \rceil \rfloor \rho \rightangle \rightarrow
\rightbrace \rightbracket \rightharpoondown \rightharpoonup
\rightparen \searrow \sharp \sigma \sim \simeq \slash \smile
\spadesuit \sqcap \sqcup \sqrt \sqsubseteq \sqsupseteq \subset
\subseteq \succ \succeq \sum \supset \supseteq \swarrow \tau \theta
\times \top \triangleleft \triangleright \uparrow \updownarrow
\uplus \upsilon \varepsilon \varphi \varphi \varrho \varsigma
\vartheta \vdash \vee \vert \wedge \wp \wr \xi \zeta
BACKENDS
mathtext currently works with GTK, Agg, GTKAgg, TkAgg and WxAgg and
PS, though only horizontal and vertical rotations are supported in
*Agg
mathtext now embeds the TrueType computer modern fonts into the PS
file, so what you see on the screen should be what you get on paper.
Backends which don't support mathtext will just render the TeX
string as a literal. Stay tuned.
KNOWN ISSUES:
- nested subscripts, eg, x_i_j not working; but you can do x_{i_j}
- nesting fonts changes in sub/superscript groups not parsing
- I would also like to add a few more layout commands, like \frac.
Author : John Hunter <jdhunter@ace.bsd.uchicago.edu>
Copyright : John Hunter (2004,2005)
License : matplotlib license (PSF compatible)
Modules | ||||||
|
Classes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Functions | ||
|
Data | ||
absolute = <ufunc 'absolute'> accent = accent alphanums = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' alphas = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ampersand = "&" at = "@" bakoma_fonts = [] binop = {{{"+" | "-"} | "*"} | "/"} bslash = "\" cal = "cal" char = W:(abcd...) charOverChars = {r'\angstrom': (('rm', 'A', 1.0), (None, r'\circ', 0.5), 0.0)} cmkern = {'cmex10': {}, 'cmmi10': {('9', 'A'): -0.055555, ('9', 'M'): -0.055555, ('9', 'N'): -0.055555, ('9', 'Y'): 0.055555, ('9', 'Z'): -0.055555, ('d', 'Y'): 0.055555, ('d', 'Z'): -0.055555, ('d', 'f'): -0.16666700000000001, ('d', 'j'): -0.111112}, 'cmr10': {('A', 'C'): -0.027779000000000002, ('A', 'G'): -0.027779000000000002, ('A', 'O'): -0.027779000000000002, ('A', 'Q'): -0.027779000000000002, ('A', 'T'): -0.083334000000000005, ('A', 'U'): -0.027779000000000002, ('A', 'V'): -0.111112, ('A', 'W'): -0.111112, ('A', 'Y'): -0.083334000000000005, ('A', 't'): -0.027779000000000002, ...}, 'cmsy10': {}, 'cmtt10': {}} colon = ":" comma = "," composite = composite div = "/" division = _Feature((2, 2, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 8192) equals = "=" exclamation = "!" expression = expression font = font fontManager = <matplotlib.font_manager.FontManager instance> fontname = {{{"rm" | "cal"} | "it"} | "tt"} group = group grouping = {{{"[" | "]"} | "("} | ")"} handler = <matplotlib.mathtext.Handler instance> italics = "it" langle = "<" latex_to_bakoma = {'(': ('cmr10', 119), ')': ('cmr10', 68), '*': ('cmsy10', 9), '+': ('cmr10', 76), ',': ('cmmi10', 44), '-': ('cmsy10', 17), '.': ('cmmi10', 51), '/': ('cmmi10', 98), '0': ('cmr10', 40), '1': ('cmr10', 100), ...} latex_to_standard = {r'\Delta': ('psyr', 68), r'\Diamond': ('psyr', 224), r'\Downarrow': ('psyr', 223), r'\Gamma': ('psyr', 89), r'\Im': ('psyr', 193), r'\Leftarrow': ('psyr', 220), r'\Leftrightarrow': ('psyr', 219), r'\Phi': ('psyr', 70), r'\Pi': ('psyr', 213), r'\Re': ('psyr', 194), ...} lbrace = Suppress:("{") lbrack = "[" lparen = "(" math_parse_s_ft2font = <matplotlib.mathtext.math_parse_s_ft2font_common instance> math_parse_s_ft2font_svg = <matplotlib.mathtext.math_parse_s_ft2font_common instance> math_parse_s_pdf = <matplotlib.mathtext.math_parse_s_ft2font_common instance> math_parse_s_ps = <matplotlib.mathtext.math_parse_s_ft2font_common instance> minus = "-" misc = {{{"!" | "@"} | "%"} | "&"} number = Combine:({{W:(0123...) ["."]} [W:(0123...)]}) nums = '0123456789' over = "over" overUnder = {"over" | "under"} overunder = {r'\coprod': 1, r'\int': 1, r'\prod': 1, r'\sum': 1} percent = "%" period = "." plus = "+" punctuation = {{{":" | ","} | "."} | ";"} rangle = ">" rbrace = Suppress:("}") rbrack = "]" rcParams = {'axes.axisbelow': False, 'axes.edgecolor': 'k', 'axes.facecolor': 'w', 'axes.grid': False, 'axes.hold': True, 'axes.labelcolor': 'k', 'axes.labelsize': 'medium', 'axes.linewidth': 1.0, 'axes.titlesize': 'large', 'backend': 'GTKAgg', ...} relation = {{"<" | ">"} | "="} roman = "rm" rparen = ")" semicolon = ";" space = {FollowedBy:("\") space} subscript = subscript subsuperscript = subsuperscript superscript = superscript symbol = Re:('(\\\\[a-zA-Z0-9]+(?!{))|([a-zA-Z0-9 ])|([+\\-*/])|([<>=])|([:,.;!])|([!@%&])|([[\\]()])') symgroup = {{font | group} | Re:('(\\\\[a-zA-Z0-9]+(?!{))|(...+\\-*/])|([<>=])|([:,.;!])|([!@%&])|([[\\]()])')} tex2type1 = {'AA': 'uni212B', 'AE': 'AE', 'BbbC': 'uni2102', 'BbbN': 'uni2115', 'BbbP': 'uni2119', 'BbbQ': 'uni211A', 'BbbR': 'uni211D', 'BbbZ': 'uni2124', 'Bumpeq': 'uni224E', 'Cap': 'uni22D2', ...} tex2uni = {'AA': 8491, 'AE': 198, 'BbbC': 8450, 'BbbN': 8469, 'BbbP': 8473, 'BbbQ': 8474, 'BbbR': 8477, 'BbbZ': 8484, 'Bumpeq': 8782, 'Cap': 8914, ...} texsym = Combine:({{"\" W:(abcd...)} ~{"{"}}) times = "*" type12uni = {'A': 65, 'AE': 198, 'Aacute': 193, 'Acircumflex': 194, 'Adieresis': 196, 'Agrave': 192, 'Aring': 197, 'Atilde': 195, 'B': 66, 'C': 67, ...} typewriter = "tt" under = "under" uni2type1 = {32: 'space', 33: 'exclam', 34: 'quotedbl', 35: 'numbersign', 36: 'dollar', 37: 'percent', 38: 'ampersand', 39: 'quotesingle', 40: 'parenleft', 41: 'parenright', ...} verbose = <matplotlib.Verbose instance> |