Matplotlib协调. sys原点到左上方 [英] Matplotlib coord. sys origin to top left
问题描述
如何将matplotlib图的原点翻转到左上角-而不是默认的左下角?我正在使用matplotlib.pylab.plot生成绘图(尽管如果有另一个更灵活的绘图例程,请告诉我).
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 (though if there is another plotting routine that is more flexible, please let me know).
我正在寻找与matlab命令等效的命令:axis ij;
I'm looking for the equivalent of the matlab command: axis ij;
此外,我花了几个小时浏览matplotlib帮助和google,但没有找到答案.一些有关我可以在哪里查找答案的信息也会有所帮助.
Also, I've spent a couple hours surfing matplotlib help and google but haven't come up with an answer. Some info on where I could have looked up the answer would be helpful as well.
推荐答案
对于图像或轮廓图,可以使用关键字origin = None | 'lower' | 'upper'
;对于线图,可以将ylimit设置为高到低.
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()
这篇关于Matplotlib协调. sys原点到左上方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!