I was trying to use %matplotlib widget to achieve interactivity in Jupiter Lab. But the output plot and widgets only showed up as texts. How to make the actual plot and widgets show up?
%matplotlib widget
import matplotlib.pyplot as plt
plt.figure()
x = [1,2,3]
y = [4,5,6]
plt.plot(x,y)
Output:
Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …
[1]:
[<matplotlib.lines.Line2D at 0x114777b38>]
The inline option with the %matplotlib magic function renders the plot out cell even if show() function of plot object is not called. The show() function causes the figure to be displayed below in[] cell without out[] with number. Now, add plt. show() at the end and run the cell again to see the difference.
The %matplotlib magic command sets up your Jupyter Notebook for displaying plots with Matplotlib. The standard Matplotlib graphics backend is used by default, and your plots will be displayed in a separate window.
Jupyter Widgets are interactive browser controls for Jupyter notebooks. Examples include: Basic form controls like sliders, checkboxes, text inputs. Container controls like tabs, accordions, horizontal and vertical layout boxes, grid layouts. Advanced controls like maps, 2d and 3d visualizations, datagrids, and more.
I know question is old, but google brought me here when I had exactly the same issue, and I eventually figured it out.
In my case, I had neglected to install @jupyter-widgets/jupyterlab-manager. Adding this via the lab extensions tab, rebuilding and reloading resolved the issue for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With