ipympl#

Since the Jupyter widget ecosystem is developing too quickly, the Matplotlib developers have decided to outsource the support to a separate module: ipympl or jupyter-matplotlib.

Installation#

ipympl is installed in both the kernel and the Jupyter environment

$ pipenv install ipympl
Installing ipympl…
Adding ipympl to Pipfile's [packages]…
✔ Installation Succeeded
…

Then you can activate the Jupyter backend in notebooks by using the following Matplotlib-Magic:

[1]:
%matplotlib widget

Examples#

Simple Matplotlib interaction#

[2]:
import matplotlib.pyplot as plt
import numpy as np


plt.figure(1)
plt.plot(np.sin(np.linspace(0, 20, 100)))
plt.show()

3D plot: subplot3d_demo.py#

[3]:
from mpl_toolkits.mplot3d import axes3d


fig = plt.figure()
ax = fig.add_subplot(111, projection="3d")

# Grab some test data.
X, Y, Z = axes3d.get_test_data(0.05)

# Plot a basic wireframe.
ax.plot_wireframe(X, Y, Z, rstride=10, cstride=10)

fig.canvas.layout.max_width = "800px"

plt.show()