Showing index as xticks for pandas plot

后端 未结 3 2086
一向
一向 2021-02-09 12:27

I have the following dataframe and am trying to plot it, so that it shows in the x-axis the index data from 8-19.

If I do df.plot() no labels are shown at a

3条回答
  •  北恋
    北恋 (楼主)
    2021-02-09 13:13

    Until the bug in Pandas gets fixed, add this after df.plot(), no need for anything else:

    plt.xticks(range(len(df.index)), df.index)
    

提交回复
热议问题