Matplotlib in Windows Subsystem for Linux

  1. install X11 server for WSL

  2. setup Anaconda Python on WSL

  3. install Matplotlib

    conda install matplotlib
    

Non-X11 Matplotlib use

Saving plots using .savefig() is possible with or without X11 installed in WSL.

Begin the Python program code with

import matplotlib
matplotlib.use('agg')

print(matplotlib.get_backend())

you should see agg printed. This will allow writing figures to disk, but will disallow displaying them on screen.

Matplotlib errors on WSL

if

import matplotlib

gives errors like

ImportError: libSM.so.6: cannot open shared object file: No such file or directory

then consider installing X11 in Windows Subsystem for Linux.