绘制直方图

时间:2020-04-17 19:05:21

标签: python pandas matplotlib

我需要绘制以下数据的直方图,即国家/地区数量总和。

     Country         Quantity
0   United Kingdom   4263829
1   Netherlands      200128
2   EIRE             142637
3   Germany          117448
4   France           110480
5   Australia        83653
6   Sweden           35637
7   Switzerland      30325
8   Spain            26824
9   Japan            25218

到目前为止,我已经尝试过此操作,但无法自己指定轴:

df.plot(x='Country', y='Quantity', kind='hist', bins=10)

enter image description here

2 个答案:

答案 0 :(得分:2)

尝试使用bar plot而不是情节:

df.bar(x='Country', y='Quantity')

答案 1 :(得分:1)

尝试一下:

import matplotlib.pyplot as plt
plt.bar(df['Country'],df['Quantity'])
plt.show()
相关问题