我建议不要使用plt.scatter,而是使用patches.Circle 来绘制绘图(类似于this answer)。这些补丁的大小保持固定,以便您可以动态放大以检查“连接”:
import matplotlib.pyplot as plt
from matplotlib.patches import Circle # for simplified usage, import this patch
# set up some x,y coordinates and radii
x = [1.0, 2.0, 4.0]
y = [1.0, 2.0, 2.0]
r = [1/(2.0**0.5), 1/(2.0**0.5), 0.25]
fig = plt.figure()
# initialize axis, important: set the aspect ratio to equal
ax = fig.add_subplot(111, aspect='equal')
# define axis limits for all patches to show
ax.axis([min(x)-1., max(x)+1., min(y)-1., max(y)+1.])
# loop through all triplets of x-,y-coordinates and radius and
# plot a circle for each:
for x, y, r in zip(x, y, r):
ax.add_artist(Circle(xy=(x, y),
radius=r))
plt.show()
生成的图如下所示:
使用绘图窗口中的缩放选项,可以获得这样的绘图:
这个放大的版本保持了原来的圆圈大小,所以可以看到“连接”。
如果您想将圆圈更改为透明,patches.Circle 将 alpha 作为参数。只要确保在调用Circle 而不是add_artist 时插入它:
ax.add_artist(Circle(xy=(x, y),
radius=r,
alpha=0.5))