我正在努力地将脑袋缠在seaborn上。我发现了很棒的tutorial,他们在其中创建了堆积图,结果变量分成了%。我的问题是我的数据非常不平衡,因此y = 1部分几乎看不到。如何仅显示y = 1(绿色)部分而不显示为100%?即我希望y轴缩放到y = 1并完全隐藏y = 0。
table=pd.crosstab(data.education,data.y)
table.div(table.sum(1).astype(float), axis=0).plot(kind='bar', stacked=True)
plt.title('Stacked Bar Chart of Education vs Purchase')
plt.xlabel('Education')
plt.ylabel('Proportion of Customers')
plt.savefig('edu_vs_pur_stack')