jupyterlab interactive plot

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


To enable the jupyter-matplotlib backend, use the matplotlib Jupyter magic:

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

More info here jupyter-matplotlib on GitHub

Screenshot Jupyter Lab


JupyterLab 3.0+

  1. Install jupyterlab and ipympl.

    For pip users:

    pip install --upgrade jupyterlab ipympl
    

    For conda users:

    conda update -c conda-forge jupyterlab ipympl
    
  2. Restart JupyterLab.

  3. Decorate the cell containing plotting code with the header:

    %matplotlib widget
    
    # plotting code goes here
    

JupyterLab 2.0

  1. Install nodejs, e.g. conda install -c conda-forge nodejs.

  2. Install ipympl, e.g. conda install -c conda-forge ipympl.

  3. [Optional, but recommended.] Update JupyterLab, e.g.
    conda update -c conda-forge jupyterlab==2.2.9==py_0.

  4. [Optional, but recommended.] For a local user installation, run:
    export JUPYTERLAB_DIR="$HOME/.local/share/jupyter/lab".

  5. Install extensions:

     jupyter labextension install @jupyter-widgets/jupyterlab-manager
     jupyter labextension install jupyter-matplotlib
    
  6. Enable widgets: jupyter nbextension enable --py widgetsnbextension.

  7. Restart JupyterLab.

  8. Decorate with %matplotlib widget.