1import matplotlib.pyplot as plt
2import matplotlib.cm as cm
3from matplotlib.colors import Normalize
4from numpy.random import rand
5
6data = [2, 3, 5, 6, 8, 12, 7, 5]
7fig, ax = plt.subplots(1, 1)
8
9# Get a color map
10my_cmap = cm.get_cmap('jet')
11
12# Get normalize function (takes data in range [vmin, vmax] -> [0, 1])
13my_norm = Normalize(vmin=0, vmax=8)
14
15ax.bar(range(8), rand(8), color=my_cmap(my_norm(data)))
16plt.show()
17
18<div class="open_grepper_editor" title="Edit & Save To Grepper"></div>