import time
import numpy as np
import matplotlib.pyplot as plt
import math
figure1=plt.figure()
plt.ion() #必须打开交互模式
tspan=[0,0.8975979 , 1.7951958 , 2.6927937 , 3.5903916 , 4.48798951,5.38558741 ,6.28318531]
while True:
newpositon=[math.sin(t) for t in tspan]
tspan=[t+0.1 for t in tspan]
time.sleep(1)
plt.cla() #清除旧图
plt.plot(newpositon) #绘制新图
plt.pause(0.01) #使用pause 而不是show来显示 0.01是一个延迟时间