【发布时间】:2018-01-22 18:05:44
【问题描述】:
我在名为 GRADES 的列中有一系列值
Grades count
A 38616
B 658
G 16041
P 7590
C 33
我想在 matplot 中可视化 my_data 数据集中的列 GRADE。使用以下代码得到一个空白子图:
fig, ax=plt.subplots()
ax.set(xlabel="Grade", ylabel="Count", title="Grade Distribution")
ax.bar('GRADE', align='center', data=my_data)
plt.show()
【问题讨论】:
-
嗯,是因为你什么都没画?
-
ax.bar的调用签名是ax.bar(x,y, *args,**kwargs),其中 x 和 y 是条形的位置和高度。 my_data 数据集是熊猫数据框吗? -
看起来你想使用 seaborn 语法。查看 seaborn 和 matplotlib 这两个文档,然后决定要使用哪一个。
-
@ImportanceOfBeingErnest 是的
标签: python matplotlib bar-chart