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);
每小时需要有一个条,但是xticks标签仅与索引对齐。