Matplotlib coord. sys origin to top left

前端 未结 5 675
栀梦
栀梦 2020-12-14 09:26

How can I flip the origin of a matplotlib plot to be in the upper-left corner - as opposed to the default lower-left? I\'m using matplotlib.pylab.plot to produce the plot (

5条回答
  •  一向
    一向 (楼主)
    2020-12-14 09:55

    This

    plt.ylim(max(plt.ylim()), min(plt.ylim()))
    

    has an advantage over this

    plt.gca().invert_yaxis()
    

    and is that if you are in interactive mode and you repeatedly plot the same plot (maybe with updated data and having a breakpoint after the plot) the y axis won't keep inverting every time.

提交回复
热议问题