我有一个3D数据阵列(2个空间维度和1个时间维度),我正在尝试使用matplotlib.animate生成动画轮廓图.我使用此链接作为基础:
http://jakevdp.github.io/blog/2012/08/18/matplotlib-animation-tutorial/
这是我的尝试:
import numpy as np
from matplotlib import pyplot as plt
from matplotlib import animation
from numpy import array, zeros, linspace, meshgrid
from boutdata import collect
# First collect data from files
n = collect("n") # This is a routine to collect data
Nx = n.shape[1]
Nz = n.shape[2]
Ny = n.shape[3]
Nt = n.shape[0]
fig = plt.figure()
ax = plt.axes(xlim=(0, 200), ylim=(0, 100))
cont, = ax.contourf([], [], [], 500)
# initialisation function
def init():
cont.set_data([],[],[])
return cont, …Run Code Online (Sandbox Code Playgroud)