title: Customizing color bar in seaborn - heatmap
body: <p>I have a heatmap to represent discrete values.</p>
  
  <pre><code>import seaborn as sns
  import pandas as pd
  
  data = np.array([[2, 1, 1, 1, 2, 3, 3, 3, 3, 3],
                   [3, 1, 1, 1, 1, 1, 1, 1, 1, 1],
                   [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
                   [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],])
  
  x_labels = ['a', 'b', 'c', 'd']
  
  dataFrame = pd.DataFrame(data.T)
  
  #get discrete colormap
  cmap = colors.ListedColormap(['blue','red','black','yellow'])
  
  ax = sns.heatmap(dataFrame, cmap=cmap, linewidths=.5, linecolor='lightgray')
  ax.set_xticklabels(x_labels)
  ax.set_yticklabels(['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'])
  
  # Manually specify colorbar labelling after it's been generated
  colorbar = ax.collections[0].colorbar
  colorbar.set_ticks([1.3, 1.7, 2.2, 2.7])
  colorbar.set_ticklabels(['A', 'B', 'C', 'NA'])
  
  plt.show()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/YzJ4y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YzJ4y.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/FPxih.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FPxih.png" alt="enter image description here"></a></p>
  
  <p>How can I specifiy those colors in a way to represent colors = {1: 'A', 2: 'B', 3: 'C', 4: 'NA'} in data</p>