Save plot to image file instead of displaying it

This displays the figure in a GUI:

import matplotlib.pyplot as plt
plt.plot([1, 2, 3], [1, 4, 9])
plt.show()

But how do I instead save the figure to a file (e.g. foo.png)?

← Назад к списку