title: Matplotlib - Adding a categorical colorbar that matches the color plotted on a scatterplot
body: <p>I'm trying to generate a scatter plot where each point has an associated color and then to generate a colorbar with those same colors. However, when I try to generate the plot, the scatter plot has the correct colors, but they do not match the actual color bar.</p>
  <pre><code>x = embedding[:,0]
  y= embedding[:,1]
  
  fig, ax=plt.subplots(1, 1, figsize=(10,10))
  plt.scatter(x, y, c=color_list, s=1)
  plt.setp(ax, xticks=[], yticks=[])
  cbar = plt.colorbar(boundaries=np.arange(0.5, df_meta['GCT-ap'].value_counts().count()+0.5))
  cbar.set_ticks(np.arange(28))
  cbar.set_ticklabels(df_meta['GCT-ap'].unique().tolist())
  </code></pre>
  <p><code>color_list</code> is a list of hex colors for every point:
  <a href="https://i.stack.imgur.com/4gVS7.png" rel="nofollow noreferrer">enter image description here</a></p>
  <p>I want to take those same colors and use it to make a color bar with the matching ticklabels, which is contained in `df_meta['GCT-ap']:
  <a href="https://i.stack.imgur.com/n3zCr.png" rel="nofollow noreferrer">enter image description here</a></p>
  <p>The problem is that the colorbar color does not match the actual scatter plot colors:
  <a href="https://i.stack.imgur.com/FD0LP.png" rel="nofollow noreferrer">enter image description here</a></p>