JupyterLab Widgets

Default User Interface

JupyterLab by default has 6 options in the left hand side menu which are:

  • File Browser
  • Running Terminals and Kernels
  • Commands
  • Property Inspector
  • Open Tabs
  • Extensions

Install Node Javascript

Extensions are written in javascript, to use the extension manager we need to first install nodejs. This can be done so by use of Anaconda:

conda install nodejs
y

Install Jupyter Widgets (ipywidgets)

The first widget to install is the jupyter-widgets which are a perquisite for most other interactive widgets.

jupyter labextension install @jupyter-widgets/jupyterlab-manager
from ipywidgets import IntSlider
IntSlider()

Install Table of Contents (toc)

jupyter labextension install @jupyterlab/toc

Interactive MatplotLib (ipympl)

Note that

conda install ipympl

Gives an older version of ipympl which is only compatible with JupyterLab Version 1.x and is incompatible with JupyterLab Version 2.x.

You need to get the latest version from Conda forge

conda install -c conda-forge ipympl
y

import numpy as np
import matplotlib.pyplot as plt
%matplotlib widget
from mpl_toolkits.mplot3d import axes3d
x=np.array([5,6,7,8,9])
x=np.reshape(x,(1,-1))
y=np.array([1,2,3,4])
y=np.reshape(y,(-1,1))
z=np.array([[0,1,1,1,0],
             [1,2,3,2,1],
             [1,2,3,2,1],
             [0,1,1,1,0]])
(x,y)=np.meshgrid(x,y)
fig1=plt.figure(1)
fig1.clf()
ax1=fig1.add_subplot(1,1,1,projection='3d')
plot1=ax1.contour3D(x,y,z)
ax1.set_xlabel('x (µm)')
ax1.set_ylabel('y (µm)')
ax1.set_zlabel('z (counts)')
fig1.show()

Variable Inspector

jupyter labextension install @lckr/jupyterlab_variableinspector