Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Save matplotlib plot in grayscale

Tags:

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?

like image 829
jlconlin Avatar asked May 16 '11 15:05

jlconlin


People also ask

What does CMAP gray do?

Plotting the image as cmap = 'gray' converts the colors. All the work is done you can now see your image.

How do I make an image black and white in Matplotlib?

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.


1 Answers

There is an easy solution:

plt.imsave(filename, image, cmap='gray') 
like image 189
Jake Zhang Avatar answered Sep 20 '22 14:09

Jake Zhang