import matplotlib.pyplot as plt save image png code example
Example 1: how to save matplotlib figure to png
In [5]: plt.savefig('books_read.png')
Example 2: matplotlib export image
from matplotlib import pyplot as plt
plt.savefig('foo.png')
plt.savefig('foo.pdf')