在PyPlot中反转Y轴 [英] Reverse Y-Axis in PyPlot
本文介绍了在PyPlot中反转Y轴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个散布图,其中包含一堆随机的x,y坐标.当前,Y轴从0开始并上升到最大值.我希望Y轴从最大值开始一直上升到0.
I have a scatter plot graph with a bunch of random x, y coordinates. Currently the Y-Axis starts at 0 and goes up to the max value. I would like the Y-Axis to start at the max value and go up to 0.
points = [(10,5), (5,11), (24,13), (7,8)]
x_arr = []
y_arr = []
for x,y in points:
x_arr.append(x)
y_arr.append(y)
plt.scatter(x_arr,y_arr)
推荐答案
有一个新的API使其更简单.
There is a new API that makes this even simpler.
plt.gca().invert_xaxis()
和/或
plt.gca().invert_yaxis()
这篇关于在PyPlot中反转Y轴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文