Skip to content

Instantly share code, notes, and snippets.

@benmaier
Created January 12, 2023 11:42
Show Gist options
  • Save benmaier/243bdafe21511f48a30e70a2ecd44cf1 to your computer and use it in GitHub Desktop.
Save benmaier/243bdafe21511f48a30e70a2ecd44cf1 to your computer and use it in GitHub Desktop.
Enabling matplotlib widgets in jupyter notebook

How to enable interactive matplotlib widgets in jupyter notebooks

This is the minimal summary of this article for my archives.

Install jupyter notebooks locally (with --user flag to make the jupyter directory writable) and the ipympl lib, as well.

pip install jupyter --user 
pip install ipympl --user

Note that that should've happened automatically anyway, but if not, you need to install ipywidgets with pip install ipywidgets --user.

Now, you need to enable the nbextensions

jupyter nbextension enable --py --sys-prefix widgetsnbextension
jupyter nbextension install --py --symlink --sys-prefix ipympl

You might also want to install the nbextensions configurator to keep an overview

jupyter contrib nbextension install --user
@benmaier
Copy link
Author

benmaier commented Feb 1, 2023

Also make sure that you enable auto save time as extension. As per this article, you just switch over to the extension tab in any jupyter notebook, and activate the AutoSaveTime extension.

or:

jupyter nbextension enable autosavetime/main

edit ~/.local/share/jupyter/nbextensions/autosavetime/main.js or ~/Library/Jupyter/nbextensions/autosavetime/main.js

set autosavetime_set_starting_interval: true (is false per default)

@benmaier
Copy link
Author

benmaier commented Feb 2, 2023

How to enable interactive matplotlib widgets in jupyter notebooks (Ubuntu, user)

unfortunately, the extension manager doesnt show up

This is the minimal summary of this article
for my archives.

Install jupyter notebooks locally (with --user flag to make the jupyter directory writable) and the ipympl lib, as well.

pip install jupyter --user 
pip install ipympl --user

Note that that should've happened automatically anyway, but if not, you need to install ipywidgets with
pip install ipywidgets --user.

Now, you need to enable the nbextensions

jupyter nbextension install --py --symlink --user widgetsnbextension
jupyter nbextension enable --py --user widgetsnbextension
jupyter nbextension install --py --symlink --user ipympl
jupyter nbextension enable ipympl --user --py

You might also want to install the nbextensions configurator to keep an overview

pip install jupyter_contrib_nbextensions
jupyter contrib nbextension install --user
jupyter nbextension install jupyter_nbextensions_configurator --py --user --overwrite
jupyter nbextensions_configurator enable --user
jupyter nbextension enable jupyter_nbextensions_configurator --user --py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment