失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > python画动态图-Python使用matplotlib画动态图

python画动态图-Python使用matplotlib画动态图

时间:2021-10-17 22:12:27

相关推荐

python画动态图-Python使用matplotlib画动态图

import numpy as np

import matplotlib.pyplot as plt

import math

from scipy.interpolate import make_interp_spline#平滑曲线用的函数

plt.axis([0, 130,-16, 16])

xss=np.array([0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120,125,130])

ys=np.array([-1.56699, -1.55284, -1.51299, -1.44526, -1.34541, -1.20726, -1.02088, -0.775333, -0.463055,

-0.0576436, 0.475682, 1.15845, 2.00164, 2.99478, 4.13066, 5.38871, 6.73956, 8.10639, 9.43044,

10.6792, 11.8363, 12.8766, 13.7775, 14.5165, 15.0723, 15.4162, 15.5427])

plt.ion()

for k in range(20):

for i in range(101):

A=math.sin(i*math.pi/50)

yss=A*ys

x_smooth = np.linspace(xss.min(), xss.max(), 300)

y_smooth = make_interp_spline(xss, yss)(x_smooth)

plt.cla()

plt.plot(x_smooth, y_smooth,linewidth = '2', color= '#FF0000')

plt.axis([0, 130,-16, 16])

plt.show()

plt.pause(0.005)

if i==0 and k==0:input()

如果觉得《python画动态图-Python使用matplotlib画动态图》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。