Creating PDF files from Matplotlib using the PGF backend

Since matplotlib in Fedora 25 seems to be having some font issues when using latex fonts and creating pdf or ps files, a workaround is needed. Luckily, PDF files can also be created using the PGF backend. See http://matplotlib.org/users/pgf.html for details

Basically, include these lines in the python script and saving to pdf will work:

from matplotlib.backends.backend_pgf import FigureCanvasPgf
from matplotlib.backend_bases import register_backend
register_backend('pdf', FigureCanvasPgf)

If you need customization of the fonts, that may have to be done through the pgf settings; the page linked above has some examples.