How to write your own LaTeX preamble in Matplotlib?

When I need to use LaTeX with matplotlib, I add the following to the python script (+ additional commands for debug info)

 import matplotlib.pyplot as plt

 plt.rc('text', usetex=True)
 plt.rc('text.latex', preamble=r'\usepackage{amsmath}
          \usepackage{foo-name} `...')
 matplotlib.verbose.level="debug-annoying"

commands to make your plot here

Leave a Comment