Python:如何围绕给定坐标绘制圆
我目前正在尝试围绕坐标绘制给定半径的圆,以查看绘制的圆是否重叠。我目前有:Python:如何围绕给定坐标绘制圆,python,matplotlib,geometry,Python,Matplotlib,Geometry,我目前正在尝试围绕坐标绘制给定半径的圆,以查看绘制的圆是否重叠。我目前有: import matplotlib.pyplot as plt for i in range(len(b)): for j in range(len(d)): circle1=plt.Circle((b[i,0], b[i,1]), 0.5, color='r', fill=False) circle1=plt.Circle((d[j,0], d[j,1]), 0.5, col
import matplotlib.pyplot as plt
for i in range(len(b)):
for j in range(len(d)):
circle1=plt.Circle((b[i,0], b[i,1]), 0.5, color='r', fill=False)
circle1=plt.Circle((d[j,0], d[j,1]), 0.5, color='g', fill=False)
fig = plt.gcf()
fig.gca().add_artist(circle1)
fig.gca().add_artist(circle2)
fig.savefig('plotcircles.png')
b和d是每行有两个元素的列表
谢谢大家! 圆打印代码以相同的名称保存len(d)x len(b)图像,并且这些图像具有越来越多的圆(因为您仅在
plt.gcf()处隐式创建一个新图像)。如果您只想创建许多png图像,我建议您绘制两个圆一次,然后每一轮都使用其中心属性更改其位置
然而,如果你只想知道两个圈是否重叠,有更简单的方法。您需要圆的中心和两个圆的半径(r1,r2)之间的距离。如果r1+r2