title: Multiple legend to matplotlib pie chart?
body: <p>I'm coding in Python and testing Matplotlib. I'm trying to add multiple legends because I have 2 pie charts. Using this <a href="http://matplotlib.org/users/legend_guide.html" rel="nofollow noreferrer">http://matplotlib.org/users/legend_guide.html</a> I got 2 multiple legends, but with the same colours. For every pie chart, I have 2 differents colors, so I want the same colours for their respectives legends.</p>
  
  <p>Also, is it possible to put the legend closer to the border of the window? Because the legend is a long phrase and I don't want the second legend in the middle of the screen.</p>
  
  <pre><code>import matplotlib.pyplot as plt
  import matplotlib.patches as mpatches
  
  #def pieChart()
  # Data to plot
  labels = 'Participaram', 'Não participaram'
  sizes = [215, 130]
  colors = ['gold', 'yellowgreen']
  explode = (0.1, 0)  # explode 1st slice
  
  labels2 = 'Só visualizam dúvidas alheias', 'Mandaram e visualizam'
  sizes2 = [215, 130]
  colors2 = ['lightskyblue', 'lightcoral']
  explode2 = (0, 0.08)  # explode 1st slice
  
  # Plot
  plt.pie(sizes, explode=explode,  colors=colors2,autopct='%1.1f%%', shadow=True, startangle=90, center = (-2,0))
  
  plt.pie(sizes2, explode=explode2,  colors=colors,autopct='%1.1f%%', shadow=True, startangle=45, center = (2,0))
  
  first_legend = plt.legend(labels,loc = 2)
  ax = plt.gca().add_artist(first_legend)
  second_legend = plt.legend(labels2,loc = 4,ncol=1)
  
  plt.axis('equal')
  plt.show()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/lSTcu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lSTcu.png" alt="enter image description here"></a></p>