Python 熊猫周日轴标签

Python 熊猫周日轴标签,python,matplotlib,pandas,Python,Matplotlib,Pandas,我正在策划一个为期一周的熊猫系列。我的代码: rng = pd.date_range('1/6/2014',periods=169,freq='H') graph = pd.Series(shared_index, index=rng[:168]) graph.plot(shared_index) 其中显示7个x轴标签: [2014年1月06日,07、08、09、10、11、12] 但我想: [周一、周二、周三、周四、周五、周六、周日] 我应该在代码中指定什么来更改轴标签 谢谢 也许您可以手动

我正在策划一个为期一周的熊猫系列。我的代码:

rng = pd.date_range('1/6/2014',periods=169,freq='H')
graph = pd.Series(shared_index, index=rng[:168])
graph.plot(shared_index)
其中显示7个x轴标签:

[2014年1月06日,07、08、09、10、11、12]

但我想:

[周一、周二、周三、周四、周五、周六、周日]

我应该在代码中指定什么来更改轴标签


谢谢

也许您可以手动修复记号标签:

rng = pd.date_range('1/6/2014',periods=169,freq='H')
graph = pd.Series(np.random.randn(168), index=rng[:168])
ax = graph.plot()

weekday_map= {0:'MON', 1:'TUE', 2:'WED', 3:'THU',
              4:'FRI', 5:'SAT', 6:'SUN'}

xs = sorted(ax.get_xticks(minor='both'))
wd = graph.index[xs - xs[0]].map(pd.Timestamp.weekday)

ax.set_xticks(xs)
ax.set_xticks([], minor=True)
ax.set_xticklabels([weekday_map[d] for d in wd])

如果有一个使用
matplotlib.dates.WeekdayLocator的解决方案,那就太好了somehow@PrageethJayathissa这个怎么样?