title: Difficulty combining and repositioning the legends of two charts in matplotlib and pandas
body: <p>I am trying to plot two charts onto one figure, with both charts coming from the same dataframe, but one represented as a stacked bar chart and the other a simple line plot.</p>
  
  <p>When I create the plot using the following code:</p>
  
  <pre><code>combined.iloc[:, 1:10].plot(kind='bar', stacked=True, figsize=(20,10))
  combined.iloc[:, 0].plot(kind='line', secondary_y=True, use_index=False, linestyle='-', marker='o')
  plt.legend(loc='upper left', fancybox=True, framealpha=1, shadow=True, borderpad=1)
  plt.show()
  </code></pre>
  
  <p>With the <code>combined</code> data frame looking like this:</p>
  
  <p><a href="https://i.stack.imgur.com/KtI47.png" rel="noreferrer"><img src="https://i.stack.imgur.com/KtI47.png" alt="source data frame"></a></p>
  
  <p>I get the following image:</p>
  
  <p><a href="https://i.stack.imgur.com/mL2w1.png" rel="noreferrer"><img src="https://i.stack.imgur.com/mL2w1.png" alt="stacked bar chart with line number of CVEs overlaid"></a></p>
  
  <p>I am trying to combine both legends into one, and position the legend in the upper left hand corner so all the chart is visible.</p>
  
  <p>Can someone explain why <code>plt.legend()</code> only seems to be editing the line chart corresponding to the <code>combined.iloc[:, 0]</code> slice of my <code>combined</code> dataframe? If anyone can see a quick and easy way to combine and reposition the legends please let me know! I'd be most grateful.</p>