34
34
import matplotlib as mpl
35
35
from matplotlib ._animation_data import (
36
36
DISPLAY_TEMPLATE , INCLUDED_FRAMES , JS_INCLUDE , STYLE_INCLUDE )
37
- from matplotlib import cbook , rcParams , rc_context
37
+ from matplotlib import cbook
38
38
39
39
40
40
_log = logging .getLogger (__name__ )
@@ -288,17 +288,17 @@ def __init__(self, fps=5, codec=None, bitrate=None, extra_args=None,
288
288
self .frame_format = 'rgba'
289
289
290
290
if codec is None :
291
- self .codec = rcParams ['animation.codec' ]
291
+ self .codec = mpl . rcParams ['animation.codec' ]
292
292
else :
293
293
self .codec = codec
294
294
295
295
if bitrate is None :
296
- self .bitrate = rcParams ['animation.bitrate' ]
296
+ self .bitrate = mpl . rcParams ['animation.bitrate' ]
297
297
else :
298
298
self .bitrate = bitrate
299
299
300
300
if extra_args is None :
301
- self .extra_args = list (rcParams [self .args_key ])
301
+ self .extra_args = list (mpl . rcParams [self .args_key ])
302
302
else :
303
303
self .extra_args = extra_args
304
304
@@ -418,7 +418,7 @@ def bin_path(cls):
418
418
subclass. This is a class method so that the tool can be looked for
419
419
before making a particular MovieWriter subclass available.
420
420
'''
421
- return str (rcParams [cls .exec_key ])
421
+ return str (mpl . rcParams [cls .exec_key ])
422
422
423
423
@classmethod
424
424
def isAvailable (cls ):
@@ -435,7 +435,7 @@ class FileMovieWriter(MovieWriter):
435
435
'''
436
436
def __init__ (self , * args , ** kwargs ):
437
437
MovieWriter .__init__ (self , * args , ** kwargs )
438
- self .frame_format = rcParams ['animation.frame_format' ]
438
+ self .frame_format = mpl . rcParams ['animation.frame_format' ]
439
439
440
440
def setup (self , fig , outfile , dpi = None , frame_prefix = '_tmp' ,
441
441
clear_temp = True ):
@@ -802,7 +802,7 @@ def __init__(self, fps=30, codec=None, bitrate=None, extra_args=None,
802
802
803
803
# Save embed limit, which is given in MB
804
804
if embed_limit is None :
805
- self ._bytes_limit = rcParams ['animation.embed_limit' ]
805
+ self ._bytes_limit = mpl . rcParams ['animation.embed_limit' ]
806
806
else :
807
807
self ._bytes_limit = embed_limit
808
808
@@ -1046,7 +1046,7 @@ def func(current_frame: int, total_frames: int) -> Any
1046
1046
# If the writer is None, use the rc param to find the name of the one
1047
1047
# to use
1048
1048
if writer is None :
1049
- writer = rcParams ['animation.writer' ]
1049
+ writer = mpl . rcParams ['animation.writer' ]
1050
1050
elif (not isinstance (writer , str ) and
1051
1051
any (arg is not None
1052
1052
for arg in (fps , codec , bitrate , extra_args , metadata ))):
@@ -1074,15 +1074,15 @@ def func(current_frame: int, total_frames: int) -> Any
1074
1074
1075
1075
# Re-use the savefig DPI for ours if none is given
1076
1076
if dpi is None :
1077
- dpi = rcParams ['savefig.dpi' ]
1077
+ dpi = mpl . rcParams ['savefig.dpi' ]
1078
1078
if dpi == 'figure' :
1079
1079
dpi = self ._fig .dpi
1080
1080
1081
1081
if codec is None :
1082
- codec = rcParams ['animation.codec' ]
1082
+ codec = mpl . rcParams ['animation.codec' ]
1083
1083
1084
1084
if bitrate is None :
1085
- bitrate = rcParams ['animation.bitrate' ]
1085
+ bitrate = mpl . rcParams ['animation.bitrate' ]
1086
1086
1087
1087
all_anim = [self ]
1088
1088
if extra_anim is not None :
@@ -1122,12 +1122,12 @@ def func(current_frame: int, total_frames: int) -> Any
1122
1122
# TODO: Right now, after closing the figure, saving a movie won't work
1123
1123
# since GUI widgets are gone. Either need to remove extra code to
1124
1124
# allow for this non-existent use case or find a way to make it work.
1125
- with rc_context ():
1126
- if rcParams ['savefig.bbox' ] == 'tight' :
1125
+ with mpl . rc_context ():
1126
+ if mpl . rcParams ['savefig.bbox' ] == 'tight' :
1127
1127
_log .info ("Disabling savefig.bbox = 'tight', as it may cause "
1128
1128
"frame size to vary, which is inappropriate for "
1129
1129
"animation." )
1130
- rcParams ['savefig.bbox' ] = None
1130
+ mpl . rcParams ['savefig.bbox' ] = None
1131
1131
with writer .saving (self ._fig , filename , dpi ):
1132
1132
for anim in all_anim :
1133
1133
# Clear the initial frame
@@ -1313,7 +1313,7 @@ def to_html5_video(self, embed_limit=None):
1313
1313
if not hasattr (self , '_base64_video' ):
1314
1314
# Save embed limit, which is given in MB
1315
1315
if embed_limit is None :
1316
- embed_limit = rcParams ['animation.embed_limit' ]
1316
+ embed_limit = mpl . rcParams ['animation.embed_limit' ]
1317
1317
1318
1318
# Convert from MB to bytes
1319
1319
embed_limit *= 1024 * 1024
@@ -1324,9 +1324,9 @@ def to_html5_video(self, embed_limit=None):
1324
1324
path = Path (tmpdir , "temp.m4v" )
1325
1325
# We create a writer manually so that we can get the
1326
1326
# appropriate size for the tag
1327
- Writer = writers [rcParams ['animation.writer' ]]
1327
+ Writer = writers [mpl . rcParams ['animation.writer' ]]
1328
1328
writer = Writer (codec = 'h264' ,
1329
- bitrate = rcParams ['animation.bitrate' ],
1329
+ bitrate = mpl . rcParams ['animation.bitrate' ],
1330
1330
fps = 1000. / self ._interval )
1331
1331
self .save (str (path ), writer = writer )
1332
1332
# Now open and base64 encode.
@@ -1385,7 +1385,7 @@ def to_jshtml(self, fps=None, embed_frames=True, default_mode=None):
1385
1385
1386
1386
def _repr_html_ (self ):
1387
1387
'''IPython display hook for rendering.'''
1388
- fmt = rcParams ['animation.html' ]
1388
+ fmt = mpl . rcParams ['animation.html' ]
1389
1389
if fmt == 'html5' :
1390
1390
return self .to_html5_video ()
1391
1391
elif fmt == 'jshtml' :
0 commit comments