Unconquerable p 2022-08-05 19:11 采纳率: 90.9%
浏览 46
已结题

python matplotlib报错

代码:

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.animation as animation
if __name__=="__main__":
    fig = plt.figure()
    ax = Axes3D(fig,auto_add_to_figure=False)
    fig.add_axes(ax)
    ax.legend(loc="best",labels="xxx")
    ax.axis('off')
    def demo(num):
        a=num

        return create_img(a,fig,ax)
    print(1)
    ani = animation.FuncAnimation(fig, demo,fargs=[],
                                  interval=tnums)
    ani.save('test.gif')
    fig.show()

注:create_img将操作后的ax作为返回值。

结果:

1
MovieWriter stderr:
[AVFilterGraph @ 0000000002af6f00] No such filter: 'palettegen'
Error configuring filters.

Traceback (most recent call last):
  File "C:\Users\86158\AppData\Roaming\Python\Python39\site-packages\matplotlib\animation.py", line 236, in saving
    yield self
  File "C:\Users\86158\AppData\Roaming\Python\Python39\site-packages\matplotlib\animation.py", line 1177, in save
    writer.grab_frame(**savefig_kwargs)
  File "C:\Users\86158\AppData\Roaming\Python\Python39\site-packages\matplotlib\animation.py", line 356, in grab_frame
    self.fig.savefig(self._proc.stdin, format=self.frame_format,
  File "C:\Users\86158\AppData\Roaming\Python\Python39\site-packages\matplotlib\figure.py", line 3005, in savefig
    self.canvas.print_figure(fname, **kwargs)
  File "C:\Users\86158\AppData\Roaming\Python\Python39\site-packages\matplotlib\backend_bases.py", line 2255, in print_figure
    result = print_method(
  File "C:\Users\86158\AppData\Roaming\Python\Python39\site-packages\matplotlib\backend_bases.py", line 1669, in wrapper
    return func(*args, **kwargs)
  File "C:\Users\86158\AppData\Roaming\Python\Python39\site-packages\matplotlib\backends\backend_agg.py", line 455, in print_raw
    fh.write(renderer.buffer_rgba())
OSError: [Errno 22] Invalid argument

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\86158\Desktop\MEME\MathmaticGraphic\3DGraphic.py", line 905, in <module>
    Graphic_main("sin(x)=y\nz=t\ncos(y)=z",modefunc=write()._write_t_x,tnums=10,nums=10)
  File "C:\Users\86158\Desktop\MEME\MathmaticGraphic\3DGraphic.py", line 896, in Graphic_main
    ani.save('test.gif')
  File "C:\Users\86158\AppData\Roaming\Python\Python39\site-packages\matplotlib\animation.py", line 1177, in save
    writer.grab_frame(**savefig_kwargs)
  File "C:\Users\86158\AppData\Local\Programs\Python\Python39\lib\contextlib.py", line 135, in __exit__
    self.gen.throw(type, value, traceback)
  File "C:\Users\86158\AppData\Roaming\Python\Python39\site-packages\matplotlib\animation.py", line 238, in saving
    self.finish()
  File "C:\Users\86158\AppData\Roaming\Python\Python39\site-packages\matplotlib\animation.py", line 347, in finish
    self._cleanup()  # Inline _cleanup() once cleanup() is removed.
  File "C:\Users\86158\AppData\Roaming\Python\Python39\site-packages\matplotlib\animation.py", line 378, in _cleanup
    raise subprocess.CalledProcessError(
subprocess.CalledProcessError: Command '['ffmpeg', '-f', 'rawvideo', '-vcodec', 'rawvideo', '-s', '640x480', '-pix_fmt', 'rgba', '-r', '100.0', '-loglevel', 'error', '-i', 'pipe:', '-filter_complex', 'split [a][b];[a] palettegen [p];[b][p] paletteuse', '-y', 'test.gif']' returned non-zero exit status 1.

为什么?求解决

  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 8月13日
    • 修改了问题 8月6日
    • 修改了问题 8月5日
    • 创建了问题 8月5日

    悬赏问题

    • ¥15 无法输出helloworld
    • ¥15 高通uboot 打印ubi init err 22
    • ¥20 PDF元数据中的XMP媒体管理属性
    • ¥15 R语言中lasso回归报错
    • ¥15 网站突然不能访问了,上午还好好的
    • ¥15 有没有dl可以帮弄”我去图书馆”秒选道具和积分
    • ¥15 semrush,SEO,内嵌网站,api
    • ¥15 Stata:为什么reghdfe后的因变量没有被发现识别啊
    • ¥15 振荡电路,ADS仿真
    • ¥15 关于#c语言#的问题,请各位专家解答!