Chapter 9: Matplotlib

Axis labels

face William Hunter Josiah Wang

Task 3: Label yourselves!

Next, add x and y axis labels to your graph.

Label the y-axis as 'Amplitude (W)', and the x-axis as 'Time (s)'.

Axis labels

Again, see the official documentation for a hint on how to do this.

import numpy as np
import matplotlib.pyplot as plt

resolution = 1000
x = np.linspace(0, 50, resolution)
y = np.sin(x)
z = np.exp(y)

plt.figure(1)
plt.plot(x, y)
plt.title("My Graph")
plt.xlabel("Time (s)")
plt.ylabel("Amplitude (W)")
plt.show()