@@ -1102,33 +1102,31 @@ def func(current_frame: int, total_frames: int) -> Any
11021102 # TODO: Right now, after closing the figure, saving a movie won't work
11031103 # since GUI widgets are gone. Either need to remove extra code to
11041104 # allow for this non-existent use case or find a way to make it work.
1105- with mpl .rc_context ():
1106- if mpl .rcParams ['savefig.bbox' ] == 'tight' :
1107- _log .info ("Disabling savefig.bbox = 'tight', as it may cause "
1108- "frame size to vary, which is inappropriate for "
1109- "animation." )
1110- mpl .rcParams ['savefig.bbox' ] = None
1111- with writer .saving (self ._fig , filename , dpi ):
1112- for anim in all_anim :
1113- # Clear the initial frame
1114- anim ._init_draw ()
1115- frame_number = 0
1116- # TODO: Currently only FuncAnimation has a save_count
1117- # attribute. Can we generalize this to all Animations?
1118- save_count_list = [getattr (a , 'save_count' , None )
1119- for a in all_anim ]
1120- if None in save_count_list :
1121- total_frames = None
1122- else :
1123- total_frames = sum (save_count_list )
1124- for data in zip (* [a .new_saved_frame_seq () for a in all_anim ]):
1125- for anim , d in zip (all_anim , data ):
1126- # TODO: See if turning off blit is really necessary
1127- anim ._draw_next_frame (d , blit = False )
1128- if progress_callback is not None :
1129- progress_callback (frame_number , total_frames )
1130- frame_number += 1
1131- writer .grab_frame (** savefig_kwargs )
1105+ if mpl .rcParams ['savefig.bbox' ] == 'tight' :
1106+ _log .info ("Disabling savefig.bbox = 'tight', as it may cause "
1107+ "frame size to vary, which is inappropriate for "
1108+ "animation." )
1109+ with mpl .rc_context ({'savefig.bbox' : None }), \
1110+ writer .saving (self ._fig , filename , dpi ):
1111+ for anim in all_anim :
1112+ anim ._init_draw () # Clear the initial frame
1113+ frame_number = 0
1114+ # TODO: Currently only FuncAnimation has a save_count
1115+ # attribute. Can we generalize this to all Animations?
1116+ save_count_list = [getattr (a , 'save_count' , None )
1117+ for a in all_anim ]
1118+ if None in save_count_list :
1119+ total_frames = None
1120+ else :
1121+ total_frames = sum (save_count_list )
1122+ for data in zip (* [a .new_saved_frame_seq () for a in all_anim ]):
1123+ for anim , d in zip (all_anim , data ):
1124+ # TODO: See if turning off blit is really necessary
1125+ anim ._draw_next_frame (d , blit = False )
1126+ if progress_callback is not None :
1127+ progress_callback (frame_number , total_frames )
1128+ frame_number += 1
1129+ writer .grab_frame (** savefig_kwargs )
11321130
11331131 # Reconnect signal for first draw if necessary
11341132 if reconnect_first_draw :
0 commit comments