I have some color plots that I need to be saved in grayscale. Is there an easy way to do this without changing the plotting formats?
Plotting the image as cmap = 'gray' converts the colors. All the work is done you can now see your image.
To plot black-and-white binary map in matplotlib, we can create and add two subplots to the current figure using subplot() method, where nrows=1 and ncols=2. To display the data as a binary map, we can use greys colormap in imshow() method.
There is an easy solution:
plt.imsave(filename, image, cmap='gray')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With