在源代码中查看circle类:https://matplotlib.org/3.1.1/_modules/matplotlib/patches.html#circle.set_radius
我试图识别半径是英里,m还是公里。我该如何检查。
圆圈已经被绘制了,我试图手动估计查看圆圈,但不要认为这是验证的好方法
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.0873340915635142是您的距离和半径。