With the code below, one can plot this chart:
import matplotlib.pyplot as plt
import pandas as pd
df = pd.DataFrame([[55., 56.], [38., 35.], [7., 9.]], index=['Yes', 'No', "Don't know"], columns=['males', 'females'])
plt.style.use('ggplot')
df.T.plot(kind='barh', stacked=True, colormap='Blues', legend=False)
plt.xticks(range(0, 101, 10), [str(x) + "%" for x in range(0, 101, 10)])
plt.xlim([0, 100])
plt.savefig('chart.pdf', bbox_inches='tight')
I would like to have the different bars labeled with the corresponding numbers. Because the bars are stacked, the labels should be printed in the bars:
Is there an option in the pandas or matplotlib plot functions for this?