Different behavior between notebook and lab with ipython.display.html()

I don’t know if a work around is appropriate for your particular case? Or if it is generally always possible to switch the interface style…

However, for using animations in Jupyter, I found for now the old classic interface works better generally (or at least be more flexible about what works), and so I’ll sometimes find myself switching back and forth in instances launched from MyBinder.org by changing the URL on the page to end. So probably your url ends in /lab? If you edit the URL to instead end in /tree you can get back the older classic notebook style interface and try your code there.

Future tip:
Pasting your code in between code blocks that begin with three backticks, the name of the language on a line, then your code block, and then another line with three backticks again is better way to go for posting code. Alternatively, a link to a pastebin or gist might be useful for sharing code in what might be a substantial amount.