PyPlot 中的反转 Y 轴 [英] Reverse Y-Axis in PyPlot

查看:31
本文介绍了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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆