I have recently attempted to save images in Spyder using the pyplot.savefig() command as follows (imported from matplotlib), but it doesn't work:
pyplot.savefig()
E.g. code:
filename = 'myImage.png' #images contain the image shown in the Spyder Plots pane pyplot.imshow(images) pyplot.savefig(filename)
I am aware that the Plots pane has a Save button, but I want to save the image programmatically (using Python).
Please advise.
Thanks!
Use plt.imsave() to save the image. Here is the code:
plt.imsave()
import matplotlib.pyplot as plt import matplotlib.image as mpimg img = mpimg.imread('test.png') plt.imshow(img) plt.imsave("myImage.png", img) plt.show()
1.4m articles
1.4m replys
5 comments
57.0k users