from matplotlib import pyplot as plt
# As png
plt.savefig('Path/FigureName.png')
# As pdf
plt.savefig('Path/FigureName.pdf')
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(0, 10, 0.1)
y = np.sin(x)
plt.plot(x, y)
plt.savefig('saved_figure.png')
fig.write_image("images/fig1.png")
pylot save image