Formatting datetime xlabels in matplotlib (pandas df.plot() method)

前端 未结 3 849
南笙
南笙 2020-12-16 19:11

I can\'t figure out how to change the format of these x-labels. Ideally, I\'d like to call strftime(\'%Y-%m-%d\') on them. I\'ve tried things like set_ma

3条回答
  •  我在风中等你
    2020-12-16 19:37

    Simply access the tick labels and change them:

    xtl=[item.get_text()[:10] for item in ax.get_xticklabels()]
    _=ax.set_xticklabels(xtl)
    

    enter image description here

提交回复
热议问题