Module plottools.latex
Translate LaTeX texts.
Used by the text and the legend modules.
Functions
translate_latex_text(): translate text to fit both normal and LaTeX mode.
Functions
def translate_latex_text(s, **kwargs)-
Translate text to fit both normal and LaTeX mode.
Attempts to modify the string such that inpedent of whether matplotlib is in LaTeX mode (
text.usetex = True) or not, a useful result is produced. Best results are achieved, if strings are entirely written as LaTeX code.This is, in LaTeX mode (
text.usetex = True)fontstyleandfontweightarguments are translated to corresponding LaTeX commands. Some unicode characters like thin space and micro are replaced by appropriate LaTeX commands.In non-LaTeX mode, '\,' is translated to thin space, '\micro' to upright unicode micro character. Escaped '&', '%', '$', '#', '_', '{', and '}' characters are unescaped.
Parameters
s:string- The text.
kwargs:dict- Key-word arguments for the text.
fontstyle:string- In LaTeX mode, if set to
italicput text into '\textit{}' command. fontweight:string- In LaTeX mode, if set to
boldput text into '\textbf{}' command.
Returns
s:string- Translated text.
kwargs:dict- Updated and adapted key-word arguments.