Python 如何绘制动画图形

Python 如何绘制动画图形,python,pandas,matplotlib,graph,ffmpeg,Python,Pandas,Matplotlib,Graph,Ffmpeg,接下来,在构建动画绘图时,在编写ffmpeg时,我遇到以下错误: 'Requested MovieWriter ({}) not available'.format(name)) RuntimeError: Requested MovieWriter (ffmpeg) not available 收到此错误后,我最初尝试使用pip通过以下方法安装ffmpeg: python -m install ffmpeg 它似乎已经成功地安装了ffmpeg,但是回到我的代码中,我仍然得到相同的错误 在下

接下来,在构建动画绘图时,在编写ffmpeg时,我遇到以下错误:

'Requested MovieWriter ({}) not available'.format(name))
RuntimeError: Requested MovieWriter (ffmpeg) not available
收到此错误后,我最初尝试使用
pip
通过以下方法安装ffmpeg:

python -m install ffmpeg
它似乎已经成功地安装了ffmpeg,但是回到我的代码中,我仍然得到相同的错误

在下面找到我的代码:

import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.animation as animation

overdoses = pd.read_excel(r'C:\Users\ACER\Desktop\overdose_data_1999-2015.xls',sheet_name='Online',skiprows =6)

def get_data(table,rownum,title):
    data = pd.DataFrame(table.loc[rownum][2:]).astype(float)
    data.columns = {title}
    return data

title = 'Heroin Overdoses'
d = get_data(overdoses,18,title)
x = np.array(d.index)
y = np.array(d['Heroin Overdoses'])
overdose = pd.DataFrame(y,x)
overdose.columns = {title}
Writer = animation.writers['ffmpeg']
以下是堆栈跟踪:

Traceback (most recent call last):
  File "C:\Python\Python36\lib\site-packages\matplotlib\animation.py", line 161, in __getitem__
    return self.avail[name]
KeyError: 'ffmpeg'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<pyshell#18>", line 1, in <module>
    Writer = animation.writers['ffmpeg']
  File "C:\Python\Python36\lib\site-packages\matplotlib\animation.py", line 164, in __getitem__
    'Requested MovieWriter ({}) not available'.format(name))
RuntimeError: Requested MovieWriter (ffmpeg) not available
回溯(最近一次呼叫最后一次):
文件“C:\Python\Python36\lib\site packages\matplotlib\animation.py”,第161行,在\uuu getitem中__
返回self.avail[名称]
KeyError:'ffmpeg'
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
Writer=动画。writers['ffmpeg']
文件“C:\Python\Python36\lib\site packages\matplotlib\animation.py”,第164行,在\uu getitem中__
“请求的电影编写器({})不可用”。格式(名称))
运行时错误:请求的MovieWriter(ffmpeg)不可用

显然,您尚未正确安装
ffmpeg
。安装过程中几乎出现权限问题?尝试卸载/清除
ffmpeg
,然后重新安装


我看到您正试图理解为什么不干脆跳过
ffmpeg
部分,然后在最后执行
plt.show()
来查看动画。

显然,您没有正确安装
ffmpeg
。安装过程中几乎出现权限问题?尝试卸载/清除
ffmpeg
,然后重新安装

我知道您正试图理解为什么不干脆跳过
ffmpeg
部分,然后在最后做一个
plt.show()
来查看动画