title: How to create predefined color range in Matplotlib heat map from a Pandas Dataframe
body: <p>I have the following data frame:</p>
  
  <pre><code>import pandas as pd
  Index= ['aaa', 'bbb', 'ccc', 'ddd', 'eee']
  Cols = ['A', 'B', 'C', 'D']
  data= [[ 1, 0.3, 2.1, 1.3],[ 2.5, 1, 1, 0.77],[ 0.0, 1, 2, 1],[ 0, 3.2, 1, 1.2],[ 10, 1, 1, 1]]
  df = pd.DataFrame(data, index=Index, columns=Cols)
  </code></pre>
  
  <p>That looks like this:</p>
  
  <pre><code>In [25]: df
  Out[25]:
          A    B    C     D
  aaa   1.0  0.3  2.1  1.30
  bbb   2.5  1.0  1.0  0.77
  ccc   0.0  1.0  2.0  1.00
  ddd   0.0  3.2  1.0  1.20
  eee  10.0  1.0  1.0  1.00
  </code></pre>
  
  <p>What I want to do is to create a heat map with the following condition:</p>
  
  <ul>
  <li>Value &lt; 1 : Blue</li>
  <li>Value == 1 : White</li>
  <li>1 &lt; Value &lt; 2: Light Red</li>
  <li>Value >=2 : Dark red</li>
  </ul>
  
  <p>Ideally the color would have to be in gradation.
  This is my failed poor attempt:</p>
  
  <pre><code>from matplotlib import colors
  cmap = colors.ListedColormap(['darkblue','blue','white','pink','red'])
  bounds=[-0.5, 0.5, 1.5, 2.5, 3.5]
  norm = colors.BoundaryNorm(bounds, cmap.N)
  heatmap = plt.pcolor(np.array(data), cmap=cmap, norm=norm)
  plt.colorbar(heatmap, ticks=[0, 1, 2, 3])
  </code></pre>
  
  <p>Which produce this plot:</p>
  
  <p><img src="https://i.stack.imgur.com/nplQs.png" alt="enter image description here"></p>
  
  <p>What's the right way to do it?</p>