Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Widget and graph don't show up in Jupyter lab (they show up as text)

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>]
like image 603
alyishere Avatar asked Aug 01 '19 21:08

alyishere


People also ask

How do you show graphs in Jupyter notebook?

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.

Which of the following is used to display plots on the Jupyter notebook?

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.

What is Jupyter widget?

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.


1 Answers

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.

like image 102
Paidoo Avatar answered Oct 09 '22 14:10

Paidoo