title: Matplotlib: Stacked Bar Graphs
body: <p>I'm using <a href="http://matplotlib.org/examples/api/barchart_demo.html" rel="nofollow noreferrer">matplotlib's stacked bar graph example</a> with a couple of issues. Can you please help me understand why my code is not stacking the values appropriately?</p>
  
  <pre><code>N = 3
  #('PledMis', 'PledFel', 'FoundFel')
  Incarceration   = (115.3, 1.99,23.7 )   
  Probation   = (52.0, 45.9, 45.0)   
  Work   = (0, 0.3, 2.4)   
  Program   = (0, 0, 12)   
  
  ind = np.arange(N)    # the x locations for the groups
  width = 0.5           # the width of the bars: can also be len(x) sequence
  
  p1 = plt.bar(ind, Incarceration, width, color='r')
  p2 = plt.bar(ind, Probation, width, color='y',bottom=Incarceration)
  p3 = plt.bar(ind, Work, width, color='b',bottom= Probation)
  p4 = plt.bar(ind, Program, width, color='g',bottom=Work)
  
  plt.ylabel('Months')
  plt.title('Time')
  
  plt.xticks(ind+width/2, ('Found Guilty: Felony', 'Pled Guilty: Mis', 'Pled Guilty: Felony' ) )
  plt.yticks(np.arange(10,200,10))
  plt.legend ((p1[0], p2[0], p3[0], p4[0]), ('Incarceration', 'Probation','Work','Program' ))
  
  plt.show()
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/nE67v.png" alt="Output"></p>