title: Create nested barplot for each month of multiple years
body: <p>I have a dataframes df with monthly data</p>
  <pre><code>df = pd.DataFrame(
      {
          &quot;date&quot;: [
              &quot;2020-01-01&quot;,
              &quot;2020-02-01&quot;,
              &quot;2020-03-01&quot;,
              &quot;2021-01-01&quot;,
              &quot;2021-02-01&quot;,
              &quot;2021-03-01&quot;,
          ],
          &quot;cat1&quot;: [&quot;aaa&quot;, &quot;bbb&quot;, &quot;ccc&quot;, &quot;aaa&quot;, &quot;bbb&quot;, &quot;ccc&quot;],
          &quot;cat2&quot;: [&quot;hhh&quot;, &quot;kkk&quot;, &quot;lll&quot;, &quot;hhh&quot;, &quot;kkk&quot;, &quot;lll&quot;],
          &quot;cat3&quot;: [&quot;xxx&quot;, &quot;yyy&quot;, &quot;zzz&quot;, &quot;xxx&quot;, &quot;yyy&quot;, &quot;opoiuo&quot;],
          &quot;count&quot;: [1, 2, 3, 2, 3, 4],
      }
  )
  </code></pre>
  <p>I would like to plot 3 barcharts:</p>
  <ul>
  <li>with &quot;cat1&quot; in the x-axis and the &quot;count&quot; in the y-axis</li>
  <li>with &quot;cat1&quot;+&quot;cat2&quot; in the x-axis and the &quot;count&quot; in the y-axis</li>
  <li>with &quot;cat1&quot;+&quot;cat2&quot;+&quot;cat3&quot; in the x-axis and the &quot;count&quot; in the y-axis</li>
  </ul>
  <p>Since I have data from multiple years I would like to have 2 bars per year_month , one red and one blue, to compare the values from last year_month to this year_month . I think this is called a nested barplot?</p>
  <p>Something like this: <a href="https://i.stack.imgur.com/RARzx.jpg" rel="nofollow noreferrer">https://i.stack.imgur.com/RARzx.jpg</a></p>
  <p>So far I have (e.g. df2 with &quot;cat1&quot;:</p>
  <pre><code>ax = (
      df.set_index(
          [
              &quot;cat1&quot;,
          ]
      )
      .plot(kind=&quot;bar&quot;, grid=True, rot=90, figsize=(20, 5))
  )
  for p in ax.patches:
      ax.annotate(
          np.round(p.get_height(), decimals=2),
          (p.get_x() + p.get_width() / 3.0, p.get_height()),
          ha=&quot;center&quot;,
          va=&quot;center&quot;,
          xytext=(0, 6),
          textcoords=&quot;offset points&quot;,
      )
  plt.show()
  </code></pre>
  <p>but that only works with 1 year, I can't seem to get a nested barplot?</p>
  <p>I have pandas, matplotlib and seaborn installed. Whatever is easier for the plotting but preferably only one tool for all plots if possible.</p>
  <p>How can I do such nested barplots with a pandas dataframe? Examples I've found use lists and numpy + matplotlib but not dataframes.</p>