Matplotlib Jupyter Extension
ipympl is a Matplotlib Jupyter Extension that leverages the Jupyter interactive widgets framework to enable interactive features of Matplotlib within Jupyter Notebooks, JupyterLab, Google Colab, and VSCode notebooks. It provides a proper Jupyter interactive widget for figure canvases, allowing them to be positioned in interactive widget layouts. The library is actively maintained with regular releases, currently at version 0.10.0.
Warnings
- breaking For JupyterLab versions 1 or 2, `ipympl` requires manual installation of the `jupyter-matplotlib` labextension and specific version compatibility. For JupyterLab >= 3, installation via pip/conda is usually sufficient as the extension is automatically handled. Ensure your `ipympl` and `jupyter-matplotlib` versions are compatible.
- gotcha ipympl comprises both a Python (backend) and a JavaScript (frontend) component. In certain complex environments (e.g., custom Jupyter deployments, mixing environments), a version mismatch between these components can lead to non-interactive plots or errors. Always ensure both frontend and backend are from the same installation environment.
- gotcha When using `ipympl` in Google Colab, you must explicitly enable the custom widget manager before activating the Matplotlib backend, otherwise plots will not be interactive.
Install
-
pip install ipympl -
conda install -c conda-forge ipympl
Imports
- %matplotlib ipympl
%matplotlib ipympl
Quickstart
import matplotlib.pyplot as plt import numpy as np %matplotlib ipympl fig, ax = plt.subplots() x = np.linspace(0, 2 * np.pi, 100) y = np.sin(3 * x) ax.plot(x, y) plt.show()