Matplotlib

Learning outcomes

At the end of this sessions, learners …

  • understand why Matplotlib is important

  • have run Python code that uses Matplotlib

Loading Matplotlib

HPC cluster

How to load Matplotlib

Alvis

module load matplotlib/3.9.2-gfbf-2024a

COSMOS

module load matplotlib/3.8.2 (avoid version 3.9.2!)

Dardel

module load PDC/23.12 cray-python/3.11.5 matplotlib/3.8.2-cpeGNU-23.12

Kebnekaise

module load matplotlib/3.8.2

Pelle

module load matplotlib/3.9.2-gfbf-2024a

Tetralith

module load buildtool-easybuild/4.8.0-hpce082752a2 GCC/13.2.0 Python/3.11.5 SciPy-bundle/2023.11 matplotlib/3.8.2

Exercises

import matplotlib as mpl
import matplotlib.pyplot as plt

x = np.linspace(0, 10, 100)

plt.plot(x, np.sin(x))
plt.plot(x, np.cos(x))

# plt.show()
plt.figure().savefig('my_figure.png') # Unsure if this works