I am trying to create a colormap
that is a gradient from dark red
to a very light green/white
. I'll attach an example of the output as a screenshot below.
I've had a play around with the following code
:
from matplotlib import pyplot as plt
import matplotlib
import numpy as np
plt.figure()
a=np.outer(np.arange(0,1,0.01),np.ones(100))
cdict2 = {'red': [(0.0, 0.1, 0.2),
(0.3, 0.4, 0.5),
(0.5, 0.5, 0.5),
(1.0, 1.0, 1.0)],
'green': [(0.0, 0.0, 0.0),
(0.5, 0.5, 0.5),
(0.75, 1.0, 1.0),
(1.0, 1.0, 1.0)],
'blue': [(0.0, 0.0, 0.0),
(0.0, 0.0, 0.0),
(1.0, 1.0, 1.0)]}
my_cmap2 = matplotlib.colors.LinearSegmentedColormap('my_colormap2',cdict2,256)
plt.imshow(a,aspect='auto', cmap =my_cmap2)
plt.show()
But I can't get it to replicate the attached colormap
. I'm also not sure if there could be a more effective way to achieve this?
Current Output: I've manipulated the values to try and get the gradient
to replicate the attached colormap
. But I can't get the red-orange-yellow-green
gradient
correct