title: How to create a stacked bar chart for my DataFrame using seaborn
body: <p>I have a DataFrame <code>df</code>:</p>
  <pre class="lang-py prettyprint-override"><code>df = pd.DataFrame(columns=[&quot;App&quot;,&quot;Feature1&quot;, &quot;Feature2&quot;,&quot;Feature3&quot;, &quot;Feature4&quot;,&quot;Feature5&quot;, &quot;Feature6&quot;,&quot;Feature7&quot;,&quot;Feature8&quot;], data=[['SHA', 0, 0, 1, 1, 1, 0, 1, 0], ['LHA', 1, 0, 1, 1, 0, 1, 1, 0], ['DRA', 0, 0, 0, 0, 0, 0, 1, 0], ['FRA', 1, 0, 1, 1, 1, 0, 1, 1], ['BRU', 0, 0, 1, 0, 1, 0, 0, 0], ['PAR', 0, 1, 1, 1, 1, 0, 1, 0], ['AER', 0, 0, 1, 1, 0, 1, 1, 0], ['SHE', 0, 0, 0, 1, 0, 0, 1, 0]])
  
  # display(df)
     App  Feature1  Feature2  Feature3  Feature4  Feature5  Feature6  Feature7  Feature8
  0  SHA         0         0         1         1         1         0         1         0
  1  LHA         1         0         1         1         0         1         1         0
  2  DRA         0         0         0         0         0         0         1         0
  3  FRA         1         0         1         1         1         0         1         1
  4  BRU         0         0         1         0         1         0         0         0
  5  PAR         0         1         1         1         1         0         1         0
  6  AER         0         0         1         1         0         1         1         0
  7  SHE         0         0         0         1         0         0         1         0
  </code></pre>
  <p>I want to create a stacked bar chart so that each stack would correspond to <code>App</code> while the Y axis would contain the count of <code>1</code> values and the X axis would be <code>Feature</code>.</p>
  <p>It should be similar to this bar chart with the only difference that now I want to see stack bars and a legend with colors:</p>
  <pre class="lang-py prettyprint-override"><code>df_c = df.iloc[:, 1:].eq(1).sum().rename_axis('Feature').reset_index(name='Cou‌nt')
  df_c = df_c.sort_values('Cou‌nt')
  plt.figure(figsize=(12,8))
  ax = sns.barplot(x=&quot;Feature&quot;, y='Cou‌nt', data=df_c, palette=sns.color_palette(&quot;GnBu&quot;, 10))
  plt.xticks(rotation='vertical')
  ax.grid(b=True, which='major', color='#d3d3d3', linewidth=1.0)
  ax.grid(b=True, which='minor', color='#d3d3d3', linewidth=0.5)
  plt.show()
  </code></pre>
  <p><a href="https://i.stack.imgur.com/Et7w3.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Et7w3.png" alt="enter image description here" /></a></p>