I usually use the "seismic" colorbar of matplotlib.
For a publication need, I have to use black and white colors. I would like to keep the same aspect as "seismic" (i.e., blackest values for highest min and max values), as shown on the picture:
How do I make this conversion?
In my view, the best idea is to use a grey ramp instead of a diverging colourbar:
import numpy as np
import matplotlib.pyplot as plt
data = 2 * np.random.random((100, 100)) - 1
plt.imshow(data, cmap='Greys', interpolation='none')
You can use gray
as well, but it's just a reversed version and will give you white for positive values, which is not conventional for seismic data.
If you're set on doing what you ask, I think the easiest way might be to use PIL
to convert images to greyscale.
plt.imshow(data, cmap='jet', interpolation='none')
plt.savefig('image.png')
Now convert it and save:
from PIL import Image
im = Image.open('image.png')
im = im.convert('L')
im.save('image_grey.png')
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