Matplotlib installation¶
With Spack you can provide Matplotlib in your kernel, for example with:
$ spack env activate python-311
$ spack install py-matplotlib
Alternatively, you can also install Matplotlib with other package managers, for example with Pipenv:
$ pipenv install matplotlib
You can then check the installation with:
>>> import matplotlib.pyplot as plt
Note
If you get the error TclError: no display name and no $DISPLAY environment
variable
, you probably need to use the iPython backend for Matplotlib with
import matplotlib.pyplot as plt
# iPython backend for matplotlib
%matplotlib inline
If you import Matplotlib in a Python file, you must insert the following instead:
import matplotlib.pyplot as plt
# iPython backend for matplotlib
get_ipython().run_line_magic("matplotlib", "inline")