定义我的轴的限制,但使用 matplotlib 在两个方向上具有相同的比例 [英] Define the limits of my axes, but with an equal scale in both directions with matplotlib

查看:46
本文介绍了定义我的轴的限制,但使用 matplotlib 在两个方向上具有相同的比例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何组合这些语句:

pyplot.axis([1234.0, 1773.0, 497.0, 1362.0])
pyplot.axis('equal')

我只想定义我的轴的限制,但在两个方向上具有相同的比例.

I just want to define the limits of my axes, but with an equal scale in both directions.

P.S .:我尝试了 pyplot.axis([1234.0,1773.0,497.0,1362.0],'等于'),但没有用.

P.S.: I tried pyplot.axis([1234.0, 1773.0, 497.0, 1362.0], 'equal'), but didn't worked.

推荐答案

使用时比例仍然不合适

pyplot.axis([1234.0, 1773.0, 497.0, 1362.0], aspect = 'equal')

我在 StackOverflow 上进一步搜索并将代码更改为:

I searched a bit further on StackOverflow and changed my code to:

pyplot.axis([xmin, xmax, ymin, ymax])
pyplot.gca().set_aspect('equal', adjustable='box')

adjustable ='box'对于有关3D图的问题是必需的,但对于我的2D图也似乎是必需的.

The adjustable='box' was necessary for a question about a 3D plot, but seems also necessary for my 2D plot.

来源:

2D剧情问题

3D剧情问题

这篇关于定义我的轴的限制,但使用 matplotlib 在两个方向上具有相同的比例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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