使用 python 由点组成圆圈

make a circle from dots using python

有人可以帮助我使用 matplotlib 或 matplotlib 和 numpy 画一个圆。我有一组具有 x 和 y 坐标的点。 set of points

然后我需要从这个集合中取出将形成一个圆圈的点。结果应该是 a circle

import numpy
import matplotlib.pyplot as plt

X = list(range(1, 101))
Y = list(range(1, 101))


x = numpy.array(X)
y = numpy.array(Y)

xgrid, ygrid = numpy.meshgrid(x, y)

plt.style.use('seaborn')
fig, ax = plt.subplots()

ax.scatter(xgrid, ygrid, s=5, color='green')

ax.set_title('net 100х100',
    fontfamily = 'monospace',
    fontstyle = 'normal',
    fontweight = 'bold',
    fontsize = 10)
ax.set_xlabel("X", fontsize=14)
ax.set_ylabel("Y", fontsize=14)

ax.tick_params(axis='both', which='major', labelsize=14)
ax.axis([0, 101, 0, 101])
plt.show()

您需要做的就是收集圆圈中的点。

import matplotlib.pyplot as plt

xgrid = []
ygrid = []

for x in range(100):
    for y in range(100):
        if (x-50)*(x-50)+(y-50)*(y-50) < 25*25:
            xgrid.append(x)
            ygrid.append(y)


plt.style.use('seaborn')
fig, ax = plt.subplots()

ax.scatter(xgrid, ygrid, s=5, color='green')
ax.tick_params(axis='both', which='major', labelsize=14)
ax.axis([0, 101, 0, 101])
plt.show()