I use matplotlib.pyplot.pcolor() to plot a heatmap with matplotlib:
import numpy as np
import matplotlib.pyplot as plt
np.random.seed(1)
data = np.sort(np.random.rand(8,12))
plt.figure()
c = plt.pcolor(data, edgecolors='k', linewidths=4, cmap='RdBu', vmin=0.0, vmax=1.0)
plt.colorbar(c)
plt.show()
How can I change the intensity of the 'RdBu'
colormap? E.g., if the color is (0, 0, 1)
, it should be transformed into (0, 0, 0.8)
. More generally,
if the color is (x, y, z)
, it should be transformed into (ax, ay, az)
, where a
is some scalar between zero and one.