我正在使用Seaborn绘制一些数据
我面临的问题是Y轴会自动缩放,而不会显示实际数字
survive_count = sns.barplot(x="Pclass", y='Survived', data=df)
消除这种情况的可能解决方案是什么
在提出了几点建议后,我试了一下
survive_count = sns.countplot(x="Pclass", hue='Survived', data=df)
survive_count.figure.savefig(my_path + '/Class vs Survival Count.png')
但不幸的是,我遇到了另一个问题
我真的很困惑为什么我会有这个倒转的图像
为了解决这个问题,我试着
plt.gca().invert_yaxis()
及
plt.ylim(reversed(plt.ylim()))
但这两种解决方案都不起作用
您可能需要使用countplot。默认情况下,条形图对值进行平均
或使用
hue
:我猜原因是seaborns bar plot计算了类别的平均值。 请查看下面的代码是否对您有帮助
相关问题 更多 >
编程相关推荐