我在尝试制作动画时使用Seaborn relplot时遇到问题。我使用Seaborn附带的一个数据集重新创建了这个问题,如下所示
我怀疑这与plt.figure()
与sns.relplot
不同有关。任何关于如何使这项工作的想法都会被广泛接受。谢谢
%matplotlib inline
import seaborn as sns
import pandas as pd
from matplotlib import pyplot as plt
from celluloid import Camera
from IPython.display import HTML
import ffmpeg
df = sns.load_dataset('car_crashes')
f = plt.figure(figsize=(3,3))
camera = Camera(f)
# This might seem a little bit unnecessary, but its emulating the way I am plotting my other data source:
for i in range(0, len(df), 10):
g = sns.relplot(x='total', y='abbrev', hue='abbrev', data=df.iloc[i:i+10 , [0,7]])
plt.axis('off')
plt.title(f'THIS IS THE TITLE OF {i}')
plt.gca().set_aspect('equal')
camera.snap()
animation = camera.animate()
HTML(animation.to_html5_video())
目前没有回答
相关问题 更多 >
编程相关推荐