0
你好,我想要有python輪廓animation.for例子每秒鐘一個波將從中心誕生並傳播到周邊。但我只想要它與[0.0, 0.8]
級別的波。輪廓和顏色均可,但動畫效果不佳。如果有人能幫助我嗎?最後我想是這樣的:帶contourf()動畫的2D行波?
有誰知道如何使時間和我的功能之間的聯繫?每當輪廓發生變化時,我已經使用time
模塊生成,但它不起作用。
%pylab nbagg
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.animation
import matplotlib.animation as animation
#### generate some x,y,z data ####
r = np.linspace(0,6, num=100)
phi = np.linspace(0, 2*np.pi, num=200)
R, Phi = np.meshgrid(r,phi)
x = R*np.cos(Phi)
y = R*np.sin(Phi)
z = R
##################################
fig, ax=plt.subplots()
def data(x,y,z,i):
x = R*np.cos(Phi)
y = R*np.sin(Phi)
z = R-i
return z
def draw(i):
Z = data(x,y,z,i)
colors=('y','b')
levels = [0.0,0.8]
contourf(x,y,z,colors=('b', 'b', 'b', 'b', 'b', 'b', 'b','b'))
contourf(x,y,Z,levels=levels,colors=('y', 'b', 'b', 'b', 'b', 'b', 'b','b'))
#colorbar()
def animate(i):
ax.clear()
draw(i)
return ax,
draw(0)
ani = animation.FuncAnimation(fig,animate,np.arange(1, 10, .1),interval=5, blit=True)
plt.show()
好吧,它使波慢。但是我想要另一波,而第一波還在旅行。 –
對不起,我從你的帖子不明白。希望我可以拿出smth :) – Hami
我已經使用time.leep()每秒產生輪廓,但它does not工作。 –