[英]Unable to find a way to plot the data in matplotlib
I am having a data where: 我有一个数据,其中:
pd["states"] = ['AX','IP','US']
pd["CATEGORY"] = ['good','bad',......,'bad','good']
I want to plot a stacked bar chart, where states will go to x axis and y axis will have count of good and bad against each states, which should be distinguished by different colors. 我想绘制一个堆积的条形图,其中状态将进入x轴,而y轴将针对每个状态计数好坏,应该用不同的颜色来区分。
df2 = churn_df.groupby(['states', 'CATEGORY']) ['states'].count().unstack('CATEGORY').fillna(0)
df2[['good','bad']].plot(kind='bar', stacked=True, width=1)
This will help , I guess. 我想这会有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.