title: Issue with Label in Stacked Bar chart in Matplotlib from a Pandas Dataframe
body: <p>I have a Dataframe with a column (say 'Col') with values either from this list ['PO101','NI101','NE101'].</p>
  <p>Count is:</p>
  <ul>
  <li>PO101 = 30000</li>
  <li>NI101 = 5000</li>
  <li>NE101 = 3000</li>
  </ul>
  <p>I am trying to show how many are which on a stacked bar chart.</p>
  <p>I created the stacked chart using following code:</p>
  <pre><code>df.assign(dummy=1).groupby(['dummy','Col']).size().to_frame().unstack().plot(
      kind='bar',
      stacked=True,
      legend=True)
  </code></pre>
  <p>This creates the chart but the legend has weird tuple values with dummy included as below:
  <a href="https://i.stack.imgur.com/l1yTi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/l1yTi.png" alt="enter image description here" /></a></p>
  <p>So I turned the legend as False in the above and used the following manner to generate new legend.</p>
  <pre><code>current_handles, _ = plt.gca().get_legend_handles_labels()
  reversed_handles = reversed(current_handles)
  labels = reversed(df['Col'].unique())
  plt.legend(reversed_handles,labels,loc='lower right')
  </code></pre>
  <p>This generated the legend with proper names, however, it doesn't show me the correct color code as seen below:
  <a href="https://i.stack.imgur.com/AZBRo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AZBRo.png" alt="enter image description here" /></a></p>
  <p>Green (which is the largest portion in the chart) should have been PO101, instead it shows as NI101.</p>
  <p>Can someone explain me why?</p>
  <p>I think that the order which it follows to generate the chart and the order with which unique values are listed might be different.</p>
  <p>Appreciating some guidance here.</p>
  <p>EDIT:
  Attaching screenshots of the chart output for your reference.</p>