我正在使用 matplotlib 动画包来创建动画图。
我正在使用赛璐珞包来简化事情,所以我可以绘制一个海底图。
我不知道为什么保存的视频中会出现一个小框:
这是我的代码:
#%%
sns.set()
plt.style.use('seaborn-pastel')
sns.set_style('white',
{"axes.axisbelow": False,
"font.sans-serif": ['Futura'],
})
sns.set_context("paper", font_scale=1.5)
#%%
fig = plt.figure()
camera = Camera(fig)
for i in range(0, len(height_sample_data)+2, 2):
plot1 = sns.scatterplot(x=0, y=height_sample_data.Height[:i],
hue=height_sample_data.col, alpha=0.75)
sns.despine(bottom=True)
plt.xticks([])
plt.xlabel("")
plt.ylabel("Height (cm)")
plt.legend("", frameon=False)
plt.text(-.1, 140, f"{i}/{len(height_sample_data)} DataPoints Plotted")
plt.xlim(-0.5, 0.5)
plt.ylim(130, 220)
camera.snap()
anim = camera.animate(blit=True)
anim.save('Chapter6/Animations/AddingDots.mp4')
我运行了几乎相同的情节(无动画)并将其保存为 png 而不是 MPEG,盒子不见了,所以它似乎与动画有关。一开始我以为是传说大纲,但我认为我隐藏得很好。
编辑:我在mac(Catalina)上并使用ffmpeg作为mpeg保护程序,通过自制软件安装。