小编Tim*_*Tim的帖子

如何在 Funcanimation 中获得 fill_ Between 形状?

我想制作一个移动图,其中曲线下方的区域在绘制曲线时被着色。

我用谷歌搜索了一下,发现我应该以某种方式创建一个补丁。然而,我不明白他们给出的任何例子,所以让我用我的具体例子来问一下:

import numpy as np
from matplotlib import pyplot as plt
from matplotlib import animation
import pylab as p

data = np.loadtext('datafile.dat', delimiter=',')
A = data[:,1]
B = data[:,2]

fig = plt.figure(figsize=(25,5), dpi=80)
ax = plt.axes(xlim=(0, 3.428), ylim=(-1,1))
line, = ax.plot([], [], lw=5)

def init():
    line.set_data([], [])
    return line,

def animate(i):
    x = A[0:(i-1)*400]
    y = B[0:(i-1)*400]
    line.set_data(x,y)
    # Here is the problem. I would now like to add the following line
    # p.fill_between(x, 0, y, facecolor = 'C0', …
Run Code Online (Sandbox Code Playgroud)

python animation matplotlib

4
推荐指数
1
解决办法
1394
查看次数

标签 统计

animation ×1

matplotlib ×1

python ×1