使用drawnow函数的正确方法是什么

2024-09-27 00:14:42 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图用drawnow()来模拟一个旋转的轮子。我使用函数draw_wheel

spokes = 3
angle = np.pi

def draw_wheel(spokes, angle):

wheel_width = 3
spoke_width = 3

# Draw outer circle. Wrapping around twice removes
# some endpoint drawing issues.
n = 200
t = np.linspace(0, n, num=n+1)
t = np.concatenate((t, t)) * 2*np.pi / n
plt.plot(np.cos(t), np.sin(t), 'k', linewidth=wheel_width)

spoke_angle = 2*np.pi / spokes

for i in range(1, spokes + 1):
    x = np.concatenate(
            (np.array([0]),
            np.array([np.cos(angle+(i-1)*spoke_angle)])), axis=0
        )
    y = np.concatenate(
            (np.array([0]),
            np.array([-np.sin(angle+(i-1)*spoke_angle)])), axis=0
        )
    plt.plot(x,y,'k', linewidth=spoke_width)

return 1

但是当我尝试将它馈送到drawnow()时,我得到一个错误:

'int' object is not callable

有什么建议吗


Tags: plotnppipltsincoswidtharray

热门问题