title: Make legend correspond to colors of scatter points in matplotlib
body: <p>I have a plot that I am generating through KMeans algorithm in scikit-learn. The clusters correspond to different colors. Here is the plot,
  <img src="https://i.stack.imgur.com/cOxVa.png" alt="enter image description here"></p>
  
  <p>I need a legend for this plot which corresponds to the cluster number in the plot. Ideally, the legend should display the color of the cluster and the label should be the cluster number. Thanks.</p>
  
  <p>EDIT: I think I should put some code since people are downvoting this</p>
  
  <pre><code>from sklearn.cluster import KMeans
  km = KMeans(n_clusters=20, init='random')   
  km.fit(df)  #df is the dataframe which contains points as coordinates
  labels = km.labels_
  plt.clf()
  fig = plt.figure()
  ax = fig.add_subplot(111, axisbg='w', frame_on=True)
  fig.set_size_inches(18.5, 10.5)
  
  # Plot the clusters on the map
  # m is a basemap object
  m.scatter(
           [geom.x for geom in map_points],
           [geom.y for geom in map_points],
           20, marker='o', lw=.25,
           c = labels.astype(float),
           alpha =0.9, antialiased=True,
           zorder=3)
  m.fillcontinents(color='#555555')
  plt.show()
  </code></pre>