다음 코드는 원 그리기의 애니메이션을 생성합니다.머리글로 마커가있는 선을 그려야합니다.
from math import cos, sin
import matplotlib.pyplot as plt
import matplotlib.animation as animation
def update_plot(num, x, y, line):
line.set_data(x[:num], y[:num])
line.axes.axis([-1.5, 1.5, -1.5, 1.5])
return line
def plot_circle():
x = []
y = []
for i in range(100):
x.append(cos(i/10.0))
y.append(sin(i/10.0))
fig, ax = plt.subplots()
line, = ax.plot(x, y, color = "k")
ani = animation.FuncAnimation(fig, update_plot, len(x), fargs=[x, y, line], interval = 1, blit = False)
plt.show()
plot_circle()
라인은 전체 무릎보다 긴, 그래서 라인이 겹치는 경우 여전히 내가 그려되고 있는지 보여주는 표시를하고 싶은 그림을 볼 수 있도록. 나는
scat = plt.scatter(0, 0)
ani = animation.FuncAnimation(fig, update_plot, len(x), fargs=[x, y, line, scat], interval = 1, blit = False)
처럼, 업데이트 호출에 산포도를 추가하고 성공하지 update_plot
에 x[num]
및 y[num]
를 사용하여 스 캐터 플롯 점의 위치를 업데이트하려고 노력했다. 이 효과를 얻으려면 어떻게해야합니까?
정말 재미있는 솔루션! – pingul