import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt bounds = np.array([-2, -1, -0.5, 0, 0.4, 0.8, 1.2, 1.6, 2]) cmap = mpl.colors.ListedColormap([plt.cm.Blues(int(255*i/7)) for i in range(8)]) norm = mpl.colors.BoundaryNorm(bounds, cmap.N) ticks = (bounds[:-1] + bounds[1:])*0.5 labels = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']