python - 如何反转 x 或 y 轴

我有一个带有一堆随机 x、y 坐标的散点图。目前 Y 轴从 0 开始并上升到最大值。我希望 Y 轴从最大值开始并上升到 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 使这变得更加简单。

plt.gca().invert_xaxis()

和/或

plt.gca().invert_yaxis()

https://stackoverflow.com/questions/2051744/

相关文章:

linux - 定义带或不带导出的变量

python - 连接两个一维 NumPy 数组

linux - 杀死分离的 screen session

python - Pandas 'count(distinct)' 等效

python - 下标序列时Python中的::(双冒号)是什么?

linux - 在 Bash 脚本中通过管道传入/传出剪贴板

linux - 如何使用 sudo 将输出重定向到我无权写入的位置?

python - 如何正确确定当前脚本目录?

python - 在 Python 3 中 generator.next() 是可见的吗?

linux - 如何将输出重定向到文件和标准输出