title: Using matplotlib's color cycle as a colormap
body: <p>It's possible to set the color cycle to match an existing colormap, but this question is asking how to do the inverse: creating a qualitative colormap from the color cycle.</p>
  
  <p>In my specific case, I've got a scatter plot with an associated array of integer class labels. My current plot looks like this:</p>
  
  <pre><code>x,y = np.random.normal(size=(2,250))
  theta = np.arctan2(y,x)
  c = np.digitize(theta, np.histogram(theta)[1])
  plt.scatter(x,y,c=c)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/4arDn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4arDn.png" alt="current scatter plot"></a></p>
  
  <p>As you can see, this doesn't do a great job of distinguishing the classes cleanly. Instead, I'd like to somehow plug in a colormap that matches the current color cycle, where label <code>i</code> corresponds to <code>color_cycle[i]</code>. If I have more classes than the color cycle has colors, that's fine, it should just wrap around like normal.</p>