Python Matplotlib

Matplotlib Labels

Adding labels to plots

Matplotlib Labels

With Pyplot, you can use the xlabel() and ylabel() functions to set a label for the x- and y-axis.

Adding Labels

import matplotlib.pyplot as plt

x = [1, 2, 3, 4, 5]
y = [2, 4, 6, 8, 10]

plt.plot(x, y)
plt.xlabel("X Axis")
plt.ylabel("Y Axis")
plt.show()