title: Discrete Color Bar with Tick labels in between colors
body: <p>I am trying to plot some data with a discrete color bar. I was following the example given (<a href="https://gist.github.com/jakevdp/91077b0cae40f8f8244a" rel="noreferrer">https://gist.github.com/jakevdp/91077b0cae40f8f8244a</a>) but the issue is this example does not work 1-1 with different spacing. For example, the spacing in the example in the link is for only increasing by 1 but my data is increasing by 0.5. You can see the output from the code I have.<a href="https://i.stack.imgur.com/ppGjJ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ppGjJ.png" alt="Example output from some random data"></a>. Any help with this would be appreciated. I know I am missing something key here but cant figure it out.</p>
  
  <pre><code>import matplotlib.pylab as plt
  import numpy as np
  
  def discrete_cmap(N, base_cmap=None):
      """Create an N-bin discrete colormap from the specified input map"""
  
      # Note that if base_cmap is a string or None, you can simply do
      #    return plt.cm.get_cmap(base_cmap, N)
      # The following works for string, None, or a colormap instance:
  
      base = plt.cm.get_cmap(base_cmap)
      color_list = base(np.linspace(0, 1, N))
      cmap_name = base.name + str(N)
      return base.from_list(cmap_name, color_list, N)
  num=11
  
  x = np.random.randn(40)
  y = np.random.randn(40)
  c = np.random.randint(num, size=40)
  
  
  plt.figure(figsize=(10,7.5))
  
  plt.scatter(x, y, c=c, s=50, cmap=discrete_cmap(num, 'jet'))
  plt.colorbar(ticks=np.arange(0,5.5,0.5))
  plt.clim(-0.5, num - 0.5)
  plt.show()
  </code></pre>