matplotlib:带有圆形补丁的轴默认限制 [英] matplotlib: Axis default limits with a Circle patch

查看:41
本文介绍了matplotlib:带有圆形补丁的轴默认限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑以下代码:

import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.gca()
circle = plt.Circle((0, 0), radius = 0.5)
ax.add_patch(circle)
print(plt.axis())
plt.show()

默认轴限制打印为:

(0.0, 1.0, 0.0, 1.0)

我不确定为什么会这样.那么,我想学习为什么?

I am not sure why this is the case. So, I would like to learn why?

PS:我知道我可以做 plt.axis('scaled'),这样我就可以看到整个圆圈.

PS: I know I can just do plt.axis('scaled') so that I can see the entire circle.

推荐答案

诸如 plot scatter 之类的绘图功能利用了 autoscale_view ().但是,add_patch 并没有调用它(来源).虽然这解释了为什么在您的示例中轴没有自动缩放,但我不确定底层设计选择是什么.

Plotting functions like plot or scatter make use of the function autoscale_view (source). However, add_patch does not call it (source). While this explains why the axes are not scaled automatically in your example, I'm not sure what the underlying design choice was.

这篇关于matplotlib:带有圆形补丁的轴默认限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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