美文网首页
数据可视化-柱状图

数据可视化-柱状图

作者: 小幸运Q | 来源:发表于2019-12-14 20:37 被阅读0次

https://www.jianshu.com/p/8bb06d3fd21b


matplotlib版

matplotlib的标准式柱状图

import matplotlib as mpl
import matplotlib.pyplot as plt
mpl.rcParams['font.sans-serif']=['SimHei']
plt.title('Survival Rate')
# 标题
x = ['c', 'a', 'd', 'b']
y = [1, 2, 3, 4]
 
plt.bar(x, y, alpha=0.5, width=0.3,label='The First Bar')
plt.legend(loc='upper left')
# bar的位置

plt.show()
image.png

seaborn版

标准柱状图

sns.barplot(x="Parch", y="Survived", data=train)
image.png

计数式柱状图

sns.countplot('Embarked',hue='Survived',data=train)
# hue(str):dataframe的列名,按照列名中的值分类形成分类的条形图
image.png

相关文章

网友评论

      本文标题:数据可视化-柱状图

      本文链接:https://www.haomeiwen.com/subject/soocnctx.html