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

前端 未结 3 1239
隐瞒了意图╮
隐瞒了意图╮ 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:11

    You can enforce a direction for each plot:

    (t,b)= ax.get_xlim()  ## Added for clarity
    if t > b:
        ax.set_xlim((b,t))
    

    or

    if ax.xaxis_inverted():
        ax.invert_xaxis()
    

    (the latter just do the explicit three-line version, though.)

提交回复
热议问题