Matplotlib coord. sys origin to top left

前端 未结 5 676
栀梦
栀梦 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 10:04

    For an image or contour plot, you can use the keyword origin = None | 'lower' | 'upper' and for a line plot, you can set the ylimits high to low.

    from pylab import *
    A = arange(25)/25.
    A = A.reshape((5,5))
    
    figure()
    imshow(A, interpolation='nearest', origin='lower')
    
    figure()
    imshow(A, interpolation='nearest')
    
    d = arange(5)
    figure()
    plot(d)
    ylim(5, 0)
    
    show()
    

提交回复
热议问题