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

Skip to content

Commit fe44357

Browse files
committed
Drop 'bbox_inches' argument if using a writer that is not temp file-based.
1 parent 5f42166 commit fe44357

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lib/matplotlib/animation.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,23 @@ def save(self, filename, writer=None, fps=None, dpi=None, codec=None,
598598
if savefig_kwargs is None:
599599
savefig_kwargs = {}
600600

601+
# FIXME: Using 'bbox_inches' doesn't currently work with writers that pipe
602+
# the data to the command because this requires a fixed frame size (see
603+
# Ryan May's reply in this thread: [1]). Thus we drop the 'bbox_inches'
604+
# argument if it exists in savefig_kwargs.
605+
#
606+
# [1] http://matplotlib.1069221.n5.nabble.com/Animation-class-let-save-accept-kwargs-which-are-passed-on-to-savefig-td39627.html
607+
#
608+
if savefig_kwargs.has_key('bbox_inches'):
609+
if not (writer in ['ffmpeg_file', 'mencoder_file'] or
610+
isinstance(writer, (FFMpegFileWriter, MencoderFileWriter))):
611+
print("Warning: discarding the 'bbox_inches' argument in " \
612+
"'savefig_kwargs' as it is only currently supported " \
613+
"with the writers 'ffmpeg_file' and 'mencoder_file' " \
614+
"(writer used: '{}').".format(writer if isinstance(writer, str)
615+
else writer.__class__.__name__))
616+
savefig_kwargs.pop('bbox_inches')
617+
601618
# Need to disconnect the first draw callback, since we'll be doing
602619
# draws. Otherwise, we'll end up starting the animation.
603620
if self._first_draw_id is not None:

0 commit comments

Comments
 (0)