【发布时间】:2021-11-02 01:41:06
【问题描述】:
为什么下面的代码不起作用?
我想使用 matplotlib 来显示本轮,如下图所示
import matplotlib.pyplot as plt
import numpy as np
from numpy import *
import math
freqList = [1,2,3]
ampList = [1,2,4]
phaseList = [0,10,20]
circles = [] #create list of circles
x = 0
y = 0
for i in range(len(freqList)):
prevx = x
prevy = y
theta = np.linspace( 0 , 2 * np.pi , 150 )
x += ampList[i] * np.cos( theta*freqList[i] + phaseList[i] )
y += ampList[i] * np.sin( theta*freqList[i] + phaseList[i] )
circle = plt.Circle((prevx, prevy), ampList[i], fill=False)
circles.append(circle)
plt.figure()
fig, ax = plt.subplots()
ax.add_patch(circles[i])
plt.axis("equal")
plt.xlim( -10 , 10 )
plt.ylim( -10 , 10 )
plt.show()
提前感谢任何能给我一些想法的人!
【问题讨论】:
标签: python numpy matplotlib plot visualization