Introduction to NumPy and Matplotlib
Chapter 9: Matplotlib
Restricting the scale
Task 7: Restrictions!
Restrict the y
scale to a range of -0.5 to 2.0
See the documentation for this function to figure out 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, "b")
plt.plot(x, z, color="r")
plt.legend(["y", "z"], loc="upper center")
plt.title("My Graph")
plt.xlabel("Time (s)")
plt.ylabel("Amplitude (W)")
plt.ylim([-0.5, 2.0])
plt.show()