Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Latex in plot()/text() - include extra latex packages


I'm desperately trying to label axes using the siunitx package, for example:

plot(..., axes_labels=['$\si{\volt}$', '\si{\second}'])
text("\SI{1}{\ampere}", (2, 2))

However, I cannot find a way how to load the package. So far I have tried:

from matplotlib import rc
rc('text', usetex=True)
rc('text.latex', preamble='\\usepackage{siunitx}')


from sage.misc.latex import latex_extra_preamble

Neither of these seems to work (\SI is either simply ignored or unknow). Furthermore, I need to use the '\text{}' macro, which seems to be unavailable as well (need to load amsmath?).

Any help most appreciated!