How to mark columns of overlaid line art from pandas DataFrame?
With the code below, you can plot a graph:
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 different bars labeled with the corresponding numbers. Since the tablets are stacked, the decals should be printed in bars:
Is there an option for pandas or matplotlib plot functions to do this?
+3
source to share
No one has answered this question yet
See similar questions:
or similar: