Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

FuncAnimation + save() takes significantly longer to complete with afigure() instance vs aFigure() one #18785

Open
Labels
@SoundSpinning

Description

@SoundSpinning

Bug report

Bug summary

FuncAnimation (as called from a .save() to a movie command), takes significantly longer to complete when passing afigure() instance type vs aFigure() one. A lot of testing performed with differently defined animations all show a similar problem, with some tests usingfigure() can take twice as long.

Code for reproduction

"""A simple `FuncAnimation` example: figure() vs Figure() Performance"""importnumpyasnpimportmatplotlib.pyplotaspltimportmatplotlib.animationasanimationfromtqdm.autoimporttqdmimporttimeplt.style.use("ggplot")# set plot stylefig,ax=plt.subplots()# this creates a figure() instancex=np.arange(0,2*np.pi,0.01)line,=ax.plot(x,np.sin(x))defanimate(i):line.set_ydata(np.sin(x+i/10.0))# update the datareturnline,# Init only required for blitting to give a clean slate.definit():line.set_ydata(np.ma.array(x,mask=True))returnline,# Run #1now=time.time()ani_f=animation.FuncAnimation(fig,animate,tqdm(np.arange(200),initial=1),init_func=init,interval=25,blit=True)plt.close()ani_f.save("ani_f.mp4")end=time.time()print(f"Run #1: `FuncAnimation` took{(end-now):.3f}s with `figure()`")# Run #2fig=plt.Figure()# this creates a Figure() instanceax=fig.add_subplot()now=time.time()ani_F=animation.FuncAnimation(fig,animate,tqdm(np.arange(200),initial=1),init_func=init,interval=25,blit=True)plt.close()ani_F.save("ani_F.mp4")end=time.time()print(f"Run #2: `FuncAnimation` took{(end-now):.3f}s with `Figure()`")

Actual outcome

image

Expected outcome

I expected the same times for both runs: usingfigure() orFigure() as input toFuncAnimation.

Matplotlib version

  • Operating system: Windows 10, 10.0.19041
  • Matplotlib version: 3.3.2
  • Matplotlib backend (print(matplotlib.get_backend())): module://ipykernel.pylab.backend_inline
  • Python version: 3.8.6
  • Jupyter version (if applicable): 6.1.4

All installed viaconda from aMiniconda3 set up. All packages are installed fromconda-forge first when available on that channel.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp