Skip to content Skip to sidebar Skip to footer

Displaying Totals Above Stacked Bars In Barchart: Matplotlib.pyplot

I am just starting out with matplotlib.pyplot and am a little stuck. Using the example in the matpltlib.pyplot documentation, I have created a stacked bar chart using the followi

Solution 1:

Try this:

for r1,r2 in zip(p1,p2):
    h1 = r1.get_height()
    h2 = r2.get_height()
    plt.text(r1.get_x()+r1.get_width()/2., h1+h2, '%s'% (h1+h2), ha = 'center', va='bottom')

Post a Comment for "Displaying Totals Above Stacked Bars In Barchart: Matplotlib.pyplot"