title: How to write a legend using dictionary keys?
body: <p>I am trying to visualize the following data: <code>dictMy = {'apple' : [[0, 1], [0, 2], [3, 2]], 'pear' : [[2, 3], [3, 5], [0, 2]], 'peach' : [[2, 5], [3, 8], [0, 0]]}</code> Here is my code:</p>
  
  <pre><code>from matplotlib.pyplot import cm
  import matplotlib.pyplot as plt
  import numpy as np
  
  
  dictMy = {'apple' : [[0, 1], [0, 2], [3, 2]], 'pear' : [[2, 3], [3, 5], [0, 2]], 'peach' : [[2, 5], [3, 8], [0, 0]]}
  
  color=iter(cm.rainbow(np.linspace(0,1,len(dictMy))))
  
  for key in dictMy:
      curLabel = key
      c=next(color)
      for item in dictMy[key]:
          x = item[0]
          y = item[1]
          plt.scatter(x,y, c = c)
      plt.legend(str(curLabel))
  plt.show()
  </code></pre>
  
  <p>Here is the output I have:</p>
  
  <p><a href="https://i.stack.imgur.com/zh84p.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zh84p.png" alt="results from code"></a></p>
  
  <p>So, I don't really get it, why does it show the legend in such a way and how this can be fixed. I more or less understand why it's the last of all keys, but I can't understand why is it split into letters. Please, help.</p>