From a table to a figure
The topic Data frames with pandas ended with tables of metrics: a row per epoch, a column per loss, a total per group. A table answers the question you asked of it. A figure shows what you did not think to ask: a trend, an outlier, two curves that drift apart.
Matplotlib is the plotting library under most of the Python ecosystem. pandas' df.plot() calls it, and so does seaborn. Most training curves, feature histograms and grids of generated images in machine-learning code are drawn with it. Install it like any package, with uv add matplotlib or python -m pip install matplotlib. The examples here were run on CPython 3.14.7 with Matplotlib 3.11.2 and NumPy 2.5.4.
Every example is a script that opens no window. It runs with the environment variable MPLBACKEND=Agg, and the block Saving without a screen explains why. This lesson cannot show pictures, so each figure is described in words.
The shortest Matplotlib program is a sequence of calls to the module pyplot. Here is losses.py:
import matplotlib.pyplot as plt
losses = [2.3, 1.1, 0.62, 0.41, 0.33, 0.30]
plt.plot(range(1, 7), losses)
plt.xlabel("epoch")
plt.ylabel("loss")
plt.savefig("losses.png")$ MPLBACKEND=Agg python losses.pyIt prints nothing and writes losses.png, 640 by 480 pixels on a white background. One blue line drops steeply from 2.3 at epoch 1 to 1.1 at epoch 2 and then flattens out towards 0.3. The bottom axis has ticks 1 to 6 and the label "epoch"; the left one is labelled "loss".
Each call changes "the current figure". plt.plot creates a figure if there is none and draws a line on it. plt.xlabel labels whichever plot is current, and plt.savefig writes the current figure to a file. The style imitates MATLAB, which Matplotlib was first written to resemble, and it is fine for one quick plot in a notebook.
With two plots it breaks. Which plot is current depends on what ran before, in your code or in a library you called. That is hidden global state, the same trouble as a global random seed, and the reason the topic NumPy arrays passed a generator from default_rng around instead.