pythonmatplotlibjupyter-lab

jupyterlab interactive plot


With old Jupyter notebooks, I could create interactive plots via:

import matplotlib.pyplot as plt
%matplotlib notebook
x = [1,2,3]
y = [4,5,6]
plt.figure()
plt.plot(x,y)

However, in JupyterLab, this gives an error:

JavaScript output is disabled in JupyterLab

I have also tried the magic (with jupyter-matplotlib installed):

%matplotlib ipympl

But that just returns:

FigureCanvasNbAgg()

Inline plots work, but they are not interactive plots:

%matplotlib inline

Solution

  • As per Georgy's suggestion, this was caused by Node.js not being installed.