title: Matplotlib stacked bar plot: need to swap x and height
body: <p>I am looking at some world ecological footprint data and I want to make a stacked bar chart of each type of footprint where the values stacked on top of each other are the same, but for different countries. So I started using 2 of the footprints just to get something working.</p>
  
  <p>This is what I got to work (sort of):</p>
  
  <pre><code>import pandas as pd
  import numpy as np
  import matplotlib.pyplot as plt
  
  # Create DataFrame from CSV file
  df = pd.read_csv('countries.csv')
  
  # Slice Series out of DF
  cropFoot = df['Cropland Footprint']
  grazeFoot = df['Grazing Footprint']
  
  # Convert Series to list
  cropFoot = list(cropFoot)
  grazeFoot = list(grazeFoot)
  
  X = range(163)    # the lists have 163 entries
  
  plt.bar(X, height=cropFoot)
  plt.bar(X, height=grazeFoot, bottom = cropFoot)
  plt.show()
  </code></pre>
  
  <p>Which generates the following plot:</p>
  
  <p><a href="https://i.stack.imgur.com/SuSjU.png" rel="noreferrer"><img src="https://i.stack.imgur.com/SuSjU.png" alt="Stacked bar chart"></a></p>
  
  <p>I have 5 separate footprints I want to display on the x-axis so that the footprint data for each country is stacked on top of one another. Essentially, right now the x-axis is showing all 163 countries with the 2 footprints stacked. I want the opposite. So I want 5 x bars with 163 countries stacked on each bar.</p>
  
  <p>Something like this (but with 163 pieces stacked, not 7):</p>
  
  <p><a href="https://i.stack.imgur.com/c7dz3.png" rel="noreferrer"><img src="https://i.stack.imgur.com/c7dz3.png" alt="Goal stacked bar"></a></p>
  
  <p>Unsurprisingly, just swapping the X and height... doesn't work. And the result doesn't make any sense at all:</p>
  
  <pre><code>plt.bar(cropFoot, height=X)
  plt.bar(grazeFoot, height=X, bottom = cropFoot)
  
  plt.show()
  </code></pre>
  
  <p>As it looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/JIsXp.png" rel="noreferrer"><img src="https://i.stack.imgur.com/JIsXp.png" alt="Makes no sense at all."></a></p>
  
  <p>Any advice on how to reverse this properly? <a href="https://www.kaggle.com/footprintnetwork/ecological-footprint" rel="noreferrer">This is the dataset I'm using</a>, sourced from Kaggle.</p>