【发布时间】:2017-02-04 11:58:20
【问题描述】:
我正在使用 pandas .plot() 绘制时间序列,并希望看到每个月都显示为 x-tick。
这是 .plot() 的结果
我试图使用其他帖子和 matplotlib documentation 中的示例并做类似的事情
ax.xaxis.set_major_locator(
dates.MonthLocator(revenue_pivot.index, bymonthday=1,interval=1))
但这删除了所有的刻度:(
我也尝试过xticks = df.index,但没有任何改变。
在 x 轴上显示更多刻度的正确方法是什么?
【问题讨论】:
-
您是否将日期解析为日期时间?
-
@DemetriP 谢谢。看起来这至少是问题的一部分。现在在使用 ax.xaxis.set_major_locator 之后,我确实看到了滴答声……唯一的问题是现在我每年只看到一个滴答声。我显然使用 MonthLocator 错误。
标签: pandas datetime matplotlib time-series