title: scatter plot with legend colored by group without multiple calls to plt.scatter
body: <p><code>pyplot.scatter</code> allows for passing to <code>c=</code> an array that corresponds to groups, which will then color the points based on those groups. However, this seems to not support generating a legend without specifically plotting each group separately. </p>
  
  <p>So, for example, a scatter plot with groups colored can be generated by iterating over the groups and plotting each separately: </p>
  
  <pre><code>import matplotlib.pyplot as plt
  from sklearn.datasets import load_iris
  feats = load_iris()['data']
  target = load_iris()['target']
  
  f, ax = plt.subplots(1)
  for i in np.unique(target):
      mask = target == i
      plt.scatter(feats[mask, 0], feats[mask, 1], label=i)
  ax.legend()
  </code></pre>
  
  <p>Which generates: </p>
  
  <p><a href="https://i.stack.imgur.com/zySCr.png" rel="noreferrer"><img src="https://i.stack.imgur.com/zySCr.png" alt="enter image description here"></a></p>
  
  <p>I can achieve a similar looking plot without iterating over each group though: </p>
  
  <pre><code>f, ax = plt.subplots(1)
  ax.scatter(feats[:, 0], feats[:, 1], c=np.array(['C0', 'C1', 'C2'])[target])
  </code></pre>
  
  <p>But I cannot figure out a way to generate a corresponding legend with this second strategy. All of the examples I've come across iterate over the groups, which seems...less than ideal. I know I can manually generate a legend, but again that seems overly cumbersome. </p>