============== Ipympl Example ============== Thebe can display output from ipympl_, which enables interactivity with matplotlib_. .. _ipympl: https://github.com/matplotlib/ipympl .. _matplotlib: https://matplotlib.org/ Setup ===== Be sure to load require.js and Font Awesome 4 before any of your thebe activation code so that the matplotlib widgets can function. .. code-block:: html Configure thebe and load it: .. code-block:: html Create a button to activate thebe: .. code-block:: html Now add between these HTML tags: .. code-block:: html
%matplotlib widgetExamples ======== Using ipympl, you can display a variety of interactive plots. Press the "Activate" button below to connect to a Jupyter server: .. raw:: html .. raw:: html 2D plot ------- .. raw:: html
%matplotlib widget import matplotlib.pyplot as plt fig, ax = plt.subplots() fig.canvas.layout.width = '7in' fig.canvas.layout.height= '5in' ax.plot([1,2,3], [4,5,3])3D plot ------- .. raw:: html
%matplotlib widget from mpl_toolkits.mplot3d import axes3d fig = plt.figure() ax = fig.add_subplot(111, projection='3d') X, Y, Z = axes3d.get_test_data(0.05) ax.plot_wireframe(X, Y, Z, rstride=10, cstride=10) plt.show()