title: MultiIndex Dataframe Bar Plot
body: <pre><code>                Item
  Date M&amp;Y State      
  2019-09  CH        4
  2019-10  CH        2
  2019-11  CH        7
           DE        6
  2020-02  CH        7
  2020-04  CH       19
           DE        1
           LI        1
  </code></pre>
  
  <pre><code>plt.figure()
  states = ['CH','DE','LI']
  #states = ['CH','DE','LI','Total']
  pos = np.arange(len(states))
  occ = [19,1,1]
  #occ = [19,1,1,21]
  bars = plt.bar(pos, occ, align='center')
  #bars = plt.bar(pos, occ, align='center', linewidth=0, color='lightslategrey')
  bars[0].set_color('#1F77B4')
  bars[1].set_color('#F26419')
  bars[2].set_color('#F6AE2D')
  plt.xticks(pos, states, alpha=0.8)
  plt.title('April Items', alpha=0.8)
  plt.tick_params(top='off', bottom='off', left='off', right='off', labelleft='off', labelbottom='on')
  for spine in plt.gca().spines.values():
      spine.set_visible(False)
  for bar in bars:
      plt.gca().text(bar.get_x() + bar.get_width()/2, bar.get_height() - 5, str(int(bar.get_height())), 
                   ha='center', color='w', fontsize=11)
  plt.show()
  </code></pre>
  
  <p>From this dataframe I would like to plot a bar plot with:</p>
  
  <ul>
  <li><em>Date M&amp;Y</em> on the x-axis</li>
  <li>Change <em>Date M&amp;Y</em> format (e.g. 2019-09: Sep 2019)</li>
  <li>For each <em>Date M&amp;Y</em> there are up to three <em>State</em> values (DE, CH, LI)</li>
  <li>I would like to plot them both stacked and not (maybe in two adjacent subplots)</li>
  </ul>
  
  <p>So far I could only work on April data as an example because I could not handle MultiIndex.</p>
  
  <p>I am still very new to python and your help is really appreciated!</p>
  
  <p><a href="https://i.stack.imgur.com/dckRP.png" rel="nofollow noreferrer">enter image description here</a></p>