Un-align animations created with to_jshtml()?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Un-align animations created with to_jshtml()?

Matthias Geier
Dear list.

I love the feature to show animations as HTML with to_jshtml() and I'm
using it in Jupyter notebooks, e.g. here:
https://splines.readthedocs.io/bezier.html

What I don't like, however, is that those animations are always
centered, because the HTML template uses this line:

    <div class="animation" align="center">

See also https://github.com/matplotlib/matplotlib/blob/c552bdc116ad518d988461a28a2dd43ca342f2ee/lib/matplotlib/_animation_data.py#L151

I've tried to work against this forced center alignment by including
this snippet in the notebook:

    <style>div.animation { width: fit-content; }</style>

But I'm wondering: is there a better way?

There must be a better way!

I would like the animations left-aligned because the normal plots are
also left-aligned.

I'm also wondering: shouldn't the alignment be an optional setting?

Furthermore, the "align" attribute of "div" elements is "obsolete" and
"deprecated" according to
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/div

Shouldn't the alignment probably be removed completely?

If I'm using to_html5_video(), the animation isn't centered either, so
this would be actually more consistent.

cheers,
Matthias
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Un-align animations created with to_jshtml()?

Ryan May-3


On Fri, Jul 27, 2018 at 7:23 PM Matthias Geier <[hidden email]> wrote:
Dear list.

I love the feature to show animations as HTML with to_jshtml() and I'm
using it in Jupyter notebooks, e.g. here:
https://splines.readthedocs.io/bezier.html

What I don't like, however, is that those animations are always
centered, because the HTML template uses this line:

    <div class="animation" align="center">

See also https://github.com/matplotlib/matplotlib/blob/c552bdc116ad518d988461a28a2dd43ca342f2ee/lib/matplotlib/_animation_data.py#L151

I've tried to work against this forced center alignment by including
this snippet in the notebook:

    <style>div.animation { width: fit-content; }</style>

But I'm wondering: is there a better way?

There must be a better way!

I would like the animations left-aligned because the normal plots are
also left-aligned.

I'm also wondering: shouldn't the alignment be an optional setting?

Furthermore, the "align" attribute of "div" elements is "obsolete" and
"deprecated" according to
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/div

Shouldn't the alignment probably be removed completely?

If I'm using to_html5_video(), the animation isn't centered either, so
this would be actually more consistent.

That seems like a convincing argument. Would you open an issue with this in it?


Ryan
 
--
Ryan May


_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Un-align animations created with to_jshtml()?

Matthias Geier
On Sat, Jul 28, 2018 at 4:46 AM, Ryan May wrote:

> On Fri, Jul 27, 2018 at 7:23 PM Matthias Geier wrote:
>>
>> Dear list.
>>
>> I love the feature to show animations as HTML with to_jshtml() and I'm
>> using it in Jupyter notebooks, e.g. here:
>> https://splines.readthedocs.io/bezier.html
>>
>> What I don't like, however, is that those animations are always
>> centered, because the HTML template uses this line:
>>
>>     <div class="animation" align="center">
>>
>> See also
>> https://github.com/matplotlib/matplotlib/blob/c552bdc116ad518d988461a28a2dd43ca342f2ee/lib/matplotlib/_animation_data.py#L151
>>
>> I've tried to work against this forced center alignment by including
>> this snippet in the notebook:
>>
>>     <style>div.animation { width: fit-content; }</style>
>>
>> But I'm wondering: is there a better way?
>>
>> There must be a better way!
>>
>> I would like the animations left-aligned because the normal plots are
>> also left-aligned.
>>
>> I'm also wondering: shouldn't the alignment be an optional setting?
>>
>> Furthermore, the "align" attribute of "div" elements is "obsolete" and
>> "deprecated" according to
>> https://developer.mozilla.org/en-US/docs/Web/HTML/Element/div
>>
>> Shouldn't the alignment probably be removed completely?
>>
>> If I'm using to_html5_video(), the animation isn't centered either, so
>> this would be actually more consistent.
>
>
> That seems like a convincing argument. Would you open an issue with this in
> it?
>
> https://github.com/matplotlib/matplotlib/issues

Thanks Ryan, I've created this issue:
https://github.com/matplotlib/matplotlib/issues/11795

In the meantime, does somebody know a better work-around?

I've realized that my work-around

    <style>div.animation { width: fit-content; }</style>

uses an experimental CSS feature which isn't available yet in all browsers.

Any other ideas?

cheers,
Matthias

> Ryan
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users