import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(0, 2*np.pi, 30)
y = np.cos(x)

fig, ax = plt.subplots()
ax.plot(x, y)
ax.set_ylim(-2, 2)

plt.show()
