Reputation: 33
I'm trying to save an image or rather a graph from an array using the plt.savefig() command
I have an array called X_train stored with many 200x200x3 images, 200 being the dimension size and 3 because it's rgb. So the shape of each element is [200, 200, 3]
This is what shows when I run plt.imshow(X_train[1000]). It works normally when I use that command to show the 1001st element of the X_train but I can't save the graph shown when I use plt.savefig() function because it gives the error...
savefig() takes 2 positional arguments but 3 were given
I think it's because of the 3rd argument; 3. How do I only pass the first 2 arguments; 200x200, so that I can use the plt.savefig() function?
Upvotes: 1
Views: 3995
Reputation: 1515
Use plt.imsave() function to store images. Try:
plt.imsave('filename.png', X_train[index])
Upvotes: 2