remove plt.close() from animations#120
Conversation
LiamPattinson
left a comment
There was a problem hiding this comment.
Looks okay, but just to be sure, has this been fully tested in Jupyter notebooks and from the terminal? Closing a fig but then returning something that uses it feels a bit sketchy.
plt.close() from animations
|
Changed it now. We could actually simplify this even more on the documentation by simply calling plt.close() which will close all figs. This would remove the |
LiamPattinson
left a comment
There was a problem hiding this comment.
Looks good, even if I'm still not 100% clear on what's going on. Is it that Jupyter notebooks keep inserting an implicit plt.show() (or equivalent), which messes up the rendering in the docs?
| # Matplotlib will attempt to display the first frame of the video | ||
| # and since we don't want that on the documentation we run in | ||
| # notebook mode | ||
| %matplotlib notebook |
There was a problem hiding this comment.
Neat, today I learned something
There was a problem hiding this comment.
Yay!! I helped :D
So from my understanding what happens is that Jupyter will always attempt to render a figure at the end of each code cell but using certain backends such as |
|
Good to know! I've seen |
Closing the figure early so that it would not display the first frame in a jupyter notebook or on the documentation is bad practice and I shouldn't have let it through in the first place. This causes a bug when using
Tkinteras seen below.To reproduce this bug using the
dataarray.epoch.animate:Alternatively if you're more interested in the general bug then you can reproduce this using this simple script: