python - 源代码的圆类中用于半径的测量单位是什么:matplotlib.patches
问题描述
查看源代码中的圆类:https ://matplotlib.org/3.1.1/_modules/matplotlib/patches.html#Circle.set_radius
我试图确定半径是英里、米还是公里。我如何检查它。
圆圈已经画好了,我试着手动估计看圆圈,但不认为这是一个很好的验证方式
class Circle(Ellipse):
"""
A circle patch.
"""
def __str__(self):
pars = self.center[0], self.center[1], self.radius
fmt = "Circle(xy=(%g, %g), radius=%g)"
return fmt % pars
@docstring.dedent_interpd
def __init__(self, xy, radius=5, **kwargs):
"""
Create true circle at center *xy* = (*x*, *y*) with given
*radius*. Unlike :class:`~matplotlib.patches.CirclePolygon`
which is a polygonal approximation, this uses Bezier splines
and is much closer to a scale-free circle.
Valid kwargs are:
%(Patch)s
"""
Ellipse.__init__(self, xy, radius * 2, radius * 2, **kwargs)
self.radius = radius
[docs] def set_radius(self, radius):
"""
Set the radius of the circle
Parameters
----------
radius : float
"""
self.width = self.height = 2 * radius
self.stale = True
[docs] def get_radius(self):
"""
Return the radius of the circle
"""
return self.width / 2.
radius = property(get_radius, set_radius)
预期:半径应以英里为单位 实际:不清楚用于半径的测量单位
解决方案
如果你塑造你的实现,比如从两点获得距离,它会给你两点之间的距离,在这里你可以选择半径。
import math
p1 = [-118.22191509999999, 34.0431494]
p2 = [-118.13458169630128, 34.04311852494086]
distance = math.sqrt( ((p1[0]-p2[0])**2)+((p1[1]-p2[1])**2) )
self.ax1.add_patch(Circle((-118.22191509999999, 34.0431494), 0.08733340915635142, fill=False))
0.08733340915635142 是您的距离和半径。
推荐阅读
- asp.net - 无法在 Edge 中使用 Asp.net Web API
- environment-variables - 如何将 Travis env 变量写入文件?
- matlab - 类文件夹不接受到 Matlab 的路径中
- c - 访问结构中的结构指针时出现分段错误
- javascript - 单击链接时将访问者重定向到登录或注册
- symfony - 我怎样才能让它在 Symfony 表单中工作时钟选择器?
- ios - 在 UIViewController 中注册 collectionView
- typescript - 是否可以在 package.json bin 中使用本地安装的 ts-node?
- networking - 如何制作脚本来测试路由器设置上的密码
- javascript - vue-cli 3 pages config 将提供 javascript 但不会触发它