Reputation: 93
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>]
Upvotes: 9
Views: 9884
Reputation: 439
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.
Upvotes: 3
Reputation: 2014
I had exactly the same problem. Apparently, there is an issue with the Jupyter Lab version and packages, see here what other users with the same problem have written.
The things that enabled the visualization of the plots for me are:
1.) Make sure that you have Jupyter Lab version > 1.0 and ipywidgets > 7.5 installed, as adviced here. Just type in a jupyter lab cell !jupyter lab --version
, !conda list ipywidgets
and check for yourself.
2.) Open Jupyter Lab from the terminal with the command jupyter lab
. I was using before a programme that was making for me a short cut, so I don't have to open the terminal, but it was opening an older version of Jupyter Lab
Upvotes: -2