x-axis inverted unexpectedly by pandas.plot(…)

前端 未结 3 1251
隐瞒了意图╮
隐瞒了意图╮ 2020-12-21 20:40

X axis was inverted automatically and unexpectedly when plotting a series of data against another series of data using pandas. Please look at my code below. How can I ensure

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-21 21:30

    I asked this question on the issue tracker of pandas, and got answer.

    daraframe.plot(..) is designed such that

    • x coordinate of points is determined based on the index (i.e. row number) of the column specified by x parameter.
    • y coordinate of points is the value of the column specified by y parameter.

    For a scatter plot, I think the above design is not suitable. The only solution I can think of is to use plt.plot direclty.

    cphlewis's workaround is also useful.

提交回复
热议问题