如何制作从0开始的熊猫条形图?

时间:2019-08-15 20:13:51

标签: python pandas bar-chart

df = pd.DataFrame({"hour": range(4,24,1), 
                   "rate": np.random.random(size = len(range(4,24,1)))
                  }, columns = ["hour", "rate"]).set_index("hour")
fig, ax = plt.subplots(1,1, figsize = (12, 8))

df.plot(kind = "bar", xlim = (0,24), ax = ax);

enter image description here

每小时需要有一个条,但是xticks标签仅与索引对齐。

1 个答案:

答案 0 :(得分:1)

为什么不只是将其他值添加到索引中?

int

enter image description here