Skip to content

Commit 13c377c

Browse files
committed
Delay resolution of animation extra_args.
This avoids a lookup error for third-party animation subclasses for which there is no corresponding rcParam.
1 parent 745dcae commit 13c377c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lib/matplotlib/animation.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,7 @@ def __init__(self, fps=5, codec=None, bitrate=None, extra_args=None,
306306
super().__init__(fps=fps, metadata=metadata)
307307

308308
self.frame_format = 'rgba'
309-
310-
if extra_args is None:
311-
self.extra_args = list(mpl.rcParams[self.args_key])
312-
else:
313-
self.extra_args = extra_args
309+
self.extra_args = extra_args
314310

315311
def _adjust_frame_size(self):
316312
if self.codec == 'h264':
@@ -573,15 +569,17 @@ class FFMpegBase:
573569
@property
574570
def output_args(self):
575571
args = ['-vcodec', self.codec]
572+
extra_args = (self.extra_args if self.extra_args is not None
573+
else mpl.rcParams[self.args_key])
576574
# For h264, the default format is yuv444p, which is not compatible
577575
# with quicktime (and others). Specifying yuv420p fixes playback on
578576
# iOS, as well as HTML5 video in firefox and safari (on both Win and
579577
# OSX). Also fixes internet explorer. This is as of 2015/10/29.
580-
if self.codec == 'h264' and '-pix_fmt' not in self.extra_args:
578+
if self.codec == 'h264' and '-pix_fmt' not in extra_args:
581579
args.extend(['-pix_fmt', 'yuv420p'])
582580
if self.bitrate > 0:
583581
args.extend(['-b', '%dk' % self.bitrate]) # %dk: bitrate in kbps.
584-
args.extend(self.extra_args)
582+
args.extend(extra_args)
585583
for k, v in self.metadata.items():
586584
args.extend(['-metadata', '%s=%s' % (k, v)])
587585

@@ -693,7 +691,9 @@ def delay(self):
693691

694692
@property
695693
def output_args(self):
696-
return [*self.extra_args, self.outfile]
694+
extra_args = (self.extra_args if self.extra_args is not None
695+
else mpl.rcParams[self.args_key])
696+
return [*extra_args, self.outfile]
697697

698698
@classmethod
699699
def bin_path(cls):

0 commit comments

Comments
 (0)