Skip to content

Commit 8cc21db

Browse files
committed
Add IPython display hook.
This is configurable using rc params, and defaults to off.
1 parent 8cdc00a commit 8cc21db

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/matplotlib/animation.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,12 @@ def to_html5_video(self):
932932
size=self._video_size,
933933
options=' '.join(options))
934934

935+
def _repr_html_(self):
936+
r'IPython display hook for rendering.'
937+
fmt = rcParams['animation.html']
938+
if fmt == 'html5':
939+
return self.to_html5_video()
940+
935941

936942
class TimedAnimation(Animation):
937943
'''

lib/matplotlib/rcsetup.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,9 @@ def validate_hinting(s):
499499

500500
validate_axis_locator = ValidateInStrings('major', ['minor', 'both', 'major'])
501501

502+
validate_movie_html_fmt = ValidateInStrings('animation.html',
503+
['html5', 'none'])
504+
502505
def validate_bbox(s):
503506
if isinstance(s, six.string_types):
504507
s = s.lower()
@@ -944,6 +947,7 @@ def __call__(self, s):
944947
'examples.directory': ['', six.text_type],
945948

946949
# Animation settings
950+
'animation.html': ['none', validate_movie_html_fmt],
947951
'animation.writer': ['ffmpeg', validate_movie_writer],
948952
'animation.codec': ['mpeg4', six.text_type],
949953
'animation.bitrate': [-1, validate_int],

0 commit comments

Comments
 (0)