Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b001785

Browse files
committed
BUG: allow custom writers when no defaults are available
1 parent 6b17b17 commit b001785

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

lib/matplotlib/animation.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -595,11 +595,6 @@ def save(self, filename, writer=None, fps=None, dpi=None, codec=None,
595595
the individual frames. This can be used to set tight bounding boxes,
596596
for example.
597597
'''
598-
if len(writers.list()) == 0:
599-
raise ValueError("Cannot save animation: no writers are "
600-
"available. Please install mencoder or "
601-
"ffmpeg to save animations.")
602-
603598
if savefig_kwargs is None:
604599
savefig_kwargs = {}
605600

@@ -662,7 +657,13 @@ def save(self, filename, writer=None, fps=None, dpi=None, codec=None,
662657
else:
663658
import warnings
664659
warnings.warn("MovieWriter %s unavailable" % writer)
665-
writer = writers.list()[0]
660+
661+
try:
662+
writer = writers.list()[0]
663+
except:
664+
raise ValueError("Cannot save animation: no writers are "
665+
"available. Please install mencoder or "
666+
"ffmpeg to save animations.")
666667

667668
verbose.report('Animation.save using %s' % type(writer),
668669
level='helpful')

0 commit comments

Comments
 (0)