8000 WIP: Fix some animation confusion by dopplershift · Pull Request #6421 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
FIX: Animations should disable savefig.bbox as necessary.
This fixes part of #6416 by resetting the 'savefig.bbox' rcParam if it
is set to 'tight'.
  • Loading branch information
dopplershift committed May 15, 2016
commit 885b6fdb849e273ebda8c84d84f5bc7fb914fd29
33 changes: 21 additions & 12 deletions lib/matplotlib/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from matplotlib.cbook import iterable, is_string_like
from matplotlib.compat import subprocess
from matplotlib import verbose
from matplotlib import rcParams, rcParamsDefault
from matplotlib import rcParams, rcParamsDefault, rc_context

# Process creation flag for subprocess to prevent it raising a terminal
# window. See for example:
Expand Down Expand Up @@ -801,17 +801,26 @@ def save(self, filename, writer=None, fps=None, dpi=None, codec=None,
# frame information to be saved later.
# TODO: Right now, after closing the figure, saving a movie won't work
# since GUI widgets are gone. Either need to remove extra code to
# allow for this non-existant use case or find a way to make it work.
with writer.saving(self._fig, filename, dpi):
for anim in all_anim:
# Clear the initial frame
anim._init_draw()
for data in zip(*[a.new_saved_frame_seq()
for a in all_anim]):
for anim, d in zip(all_anim, data):
# TODO: Need to see if turning off blit is really necessary
anim._draw_next_frame(d, blit=False)
writer.grab_frame(**savefig_kwargs)
# allow for this non-existent use case or find a way to make it work.
with rc_context():
# See above about bbox_inches savefig kwarg
if (not writer.frame_size_can_vary and
rcParams['savefig.bbox'] == 'tight'):
verbose.report("Disabling savefig.bbox = 'tight', as it is "
"not supported by "
" 6474 {0}.".format(writer.__class__.__name__),
level='helpful')
rcParams['savefig.bbox'] = None
with writer.saving(self._fig, filename, dpi):
for anim in all_anim:
# Clear the initial frame
anim._init_draw()
for data in zip(*[a.new_saved_frame_seq()
for a in all_anim]):
for anim, d in zip(all_anim, data):
# TODO: See if turning off blit is really necessary
anim._draw_next_frame(d, blit=False)
writer.grab_frame(**savefig_kwargs)

# Reconnect signal for first draw if necessary
if reconnect_first_draw:
Expand Down
0