title: Python scatterplot: how to use a colormap that has the same colors as the colorcycle
body: <p>I am trying to color clusters in a scatter plot and I managed with two different methods.</p>
  
  <p>In the first I plot iteratively each cluster, in the second I plot all the data at once and colour the clusters according to their labels [0, 1, 2, 3 ,4].</p>
  
  <p>I am happy with the result I get in <code>example1</code> and <code>example3</code> but I don't understand why the coloring changes so dramatically when coloring the clusters according to the labels instead of iteratively plotting each cluster.</p>
  
  <p>Additionally, why the second cluster (despite having always label "1") has a different color in example1 and example3?</p>
  
  <pre><code>import matplotlib.pyplot as plt
  plt.style.use('fivethirtyeight') #irrelevant here, but coherent with the examples=)
  
  fig, ax = plt.subplots(figsize=(6,4))
  for clust in range(kmeans.n_clusters):
      ax.scatter(X[kmeans.labels_==clust],Y[kmeans.labels_==clust])
      ax.set_title("example1")`
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/JZZRa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JZZRa.png" alt="example1"></a></p>
  
  <p>and</p>
  
  <pre><code>plt.figure(figsize = (6, 4))
  plt.scatter(X,Y,c=kmeans.labels_.astype(float))
  plt.title("example2")
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/yqrvH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yqrvH.png" alt="example2"></a></p>
  
  <p>(I know I can explicitly define a colormap for the second method but I couldn't find any that reproduces the results in example 1)</p>
  
  <p>Here is a minimal working example</p>
  
  <pre><code>import matplotlib.pyplot as plt
  import pandas as pd
  plt.style.use('fivethirtyeight') #irrelevant here, but coherent with the examples=)
  X=pd.Series([1, 2, 3, 4, 5, 11, 12, 13, 14, 15])
  Y=pd.Series([1,1,1,1,1,2,2,2,2,2])
  clusters=pd.Series([0,0,0,0,0,1,1,1,1,1])
  
  
  fig, ax = plt.subplots(figsize=(6,4))
  for clust in range(2):
  ax.scatter(X[clusters==clust],Y[clusters==clust])
  ax.set_title("example3")
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/paB2A.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/paB2A.png" alt="example3"></a></p>
  
  <pre><code>plt.figure(figsize = (6, 4))
  plt.scatter(X,Y, c=clusters)
  plt.title("example4")
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/OnEPm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OnEPm.png" alt="example4"></a></p>