【发布时间】:2017-03-28 18:10:47
【问题描述】:
我有一个 DataFrame df
A B
H
8 0.899160 1
9 41.659693 7
10 336.414450 20
11 8.442857 3
12 0.848837 1
13 3.298130 2
14 3.447251 2
15 7.667236 3
17 0.831579 1
16 0.000000 0
我想在一个图上绘制 2 个直方图,所以 H - 是 x 轴,A 和 B - y 轴。
无论我尝试什么,例如:
x = delivered['A']
y = delivered['B']
fig = plt.figure()
ax = fig.add_subplot(111)
x.plot(kind='hist', ax=ax)
y.plot(kind='hist', ax=ax, color='red')
或
p = df.plot(kind='hist', x=['H'])
以B 为 x 轴绘制直方图。但我需要我的 H{8,9,10,11,12,13,14,15,16,17} 作为 x 轴!
【问题讨论】:
-
你想要直方图或条形图?
-
为什么不使用 matplotlib:stackoverflow.com/questions/35878064/… 或 stackoverflow.com/questions/6871201/…
-
@jrjc 谢谢,那是我的错误。我应该删除这个问题,还是你发布一个答案然后我接受?
-
@LadenkovVladislav 你可以回答你自己的问题!