Get the image formats supported by Matplotlib

Python

Matplotlib

Get supported image formats

Luc B.

Python

Matplotlib

While Matplotlib can save figures in many image formats, the image formats it supports depends on the installed Matplotlib backends. Matplotlib can only save plots in a particular image format if the relevant backend is installed.

Code Example

Use the Figure.canvas.get_supported_filetypes() method to determine which image formats are supported. plt.savefig() will only work with these formats.

import matplotlib.pyplot as plt
fig = plt.figure()
fig.canvas.get_supported_filetypes()
{'eps': 'Encapsulated Postscript',
 'jpg': 'Joint Photographic Experts Group',
 'jpeg': 'Joint Photographic Experts Group',
 'pdf': 'Portable Document Format',
 'pgf': 'PGF code for LaTeX',
 'png': 'Portable Network Graphics',
 'ps': 'Postscript',
 'raw': 'Raw RGBA bitmap',
 'rgba': 'Raw RGBA bitmap',
 'svg': 'Scalable Vector Graphics',
 'svgz': 'Scalable Vector Graphics',
 'tif': 'Tagged Image File Format',
 'tiff': 'Tagged Image File Format'}




<Figure size 432x288 with 0 Axes>