Print PDF from Matlabplot

Saving PDF of plots from Matplotlib is an effective way to use Matplotlib plots in LaTeX or for general sharing of high quality plots. This can be accomplished by figure.savefig() to save to PDF from Matplotlib Simply use a filename with “.pdf” suffix.

Headless (fast) PDF generation: to save figures to disk without displaying them onscreen first, which is generally significantly faster:

from matplotlib.figure import Figure

fg = Figure()
ax = fg.gca()

fg.savefig('line.pdf', bbox_inches='tight', dpi=300)