From a43bf5c15c6713aace27bd92619d85102760b9c6 Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Tue, 11 Sep 2018 22:44:45 +0200 Subject: [PATCH] Improve layout of HTML animation --- lib/matplotlib/_animation_data.py | 94 +++++++++++++++++++++---------- lib/matplotlib/animation.py | 6 +- 2 files changed, 68 insertions(+), 32 deletions(-) diff --git a/lib/matplotlib/_animation_data.py b/lib/matplotlib/_animation_data.py index 4c3f2c75b65e..9892596eb28e 100644 --- a/lib/matplotlib/_animation_data.py +++ b/lib/matplotlib/_animation_data.py @@ -146,39 +146,74 @@ """ +# Style definitions for the HTML template +STYLE_INCLUDE = """ + +""" + + # HTML template for HTMLWriter DISPLAY_TEMPLATE = """ -
- -
- + +
+ -
- - - - - - - - - -
- Once - Loop - Reflect -
+
+ + + + + + + + + +
+
+ + + + + + +
+
@@ -202,6 +237,7 @@ """ + INCLUDED_FRAMES = """ for (var i=0; i<{Nframes}; i++){{ frames[i] = "{frame_dir}/frame" + ("0000000" + i).slice(-7) + diff --git a/lib/matplotlib/animation.py b/lib/matplotlib/animation.py index 5280601cbd46..3eb3fa754133 100644 --- a/lib/matplotlib/animation.py +++ b/lib/matplotlib/animation.py @@ -33,8 +33,8 @@ import numpy as np -from matplotlib._animation_data import (DISPLAY_TEMPLATE, INCLUDED_FRAMES, - JS_INCLUDE) +from matplotlib._animation_data import ( + DISPLAY_TEMPLATE, INCLUDED_FRAMES, JS_INCLUDE, STYLE_INCLUDE) from matplotlib import cbook, rcParams, rcParamsDefault, rc_context @@ -923,7 +923,7 @@ def communicate(self): interval = 1000 // self.fps with open(self.outfile, 'w') as of: - of.write(JS_INCLUDE) + of.write(JS_INCLUDE + STYLE_INCLUDE) of.write(DISPLAY_TEMPLATE.format(id=uuid.uuid4().hex, Nframes=Nframes, fill_frames=fill_frames,