title: How do I label groups on a scatterplot in matplotlib using data from dictionaries?
body: <p>I have some x,y data stored as dictionaries with the key as x and the value as y. I want to graph these on a scatter plot using matplotlib, with each dictionary treated as a category. What I've tried so far colors the points how I want but labels each point separately instead of as a group, producing dozens of identical labels in the legend at scale. Here's what I have, with some placeholder info:</p>
  <pre><code>dict1 = {1:2, 3:4, 5:6}
  dict2 = {7:8, 9:10, 11:12}
  dict3 = {13:14, 15:16, 17:18}
  
  data = (dict1, dict2, dict3)
  colors = ('r', 'g', 'b')
  groups = ('First','Second','Third')
  
  for datum, color, group in zip(data, colors, groups):
      for i in datum:
          x, y = i, datum[i]
          plt.scatter(x, y, c=color, label=group)
  
  plt.legend(loc=2)
  plt.show()
  </code></pre>
  <p>I've tried moving <code>plt.scatter()</code> out of the <code>for i in datum</code> loop, but that only plots one point per group, instead of each key:value pair. How do I get the legend to label these by category instead of by point?</p>