title: How do I give the legend a background color in matplotlib?
body: <p>The colors from the legend are blending in with the colors on my stackplot. Seemingly, this appears to be by default (as I have not touched any color settings). How would I fix this? Is there a way to give my legend a background color? I have already tried using the <code>facecolor</code> argument.</p>
  <p>Here is my code:</p>
  <pre><code>from matplotlib import pyplot as plt
  
  days = [1, 2, 3, 4, 5, 6, 7, 8, 9]
  
  # hours worked each day on the project 
  dev1 = [8, 6, 5, 5, 4, 2, 1, 1, 0]
  dev2 = [0, 1, 2, 2, 2, 4, 4, 4, 4]
  dev3 = [0, 1, 1, 1, 2, 2, 3, 3, 4]
  
  
  
  plt.style.use('fivethirtyeight')
  
  labels = ['Developer 1', 'Developer 2', 'Developer 3']
  
  
  plt.stackplot(days, dev1, dev2, dev3, labels=labels)
  
  plt.legend(loc=(0.05, 0.07))
  # plt.legend(loc=(0.05, 0.07), facecolor='white')    I have tried this as well
  plt.title('My Awesome Stack Plot')
  plt.tight_layout()
  plt.show()
  </code></pre>
  <p><a href="https://i.stack.imgur.com/No1xL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/No1xL.png" alt="enter image description here" /></a></p>