from __future__ import print_function, division %matplotlib inline import matplotlib.pyplot as plt import numpy as np x = np.linspace(0, 20, 1000) # 100 evenly-spaced values from 0 to 50 y = np.sin(x) plt.plot(x, y); plt.plot(x, y) plt.xlim(5, 15) plt.ylim(-1.2, 1.2); plt.plot(x, y) plt.xlabel('this is x!') plt.ylabel('this is y!') plt.title('My First Plot'); y = np.sin(2 * np.pi * x) plt.plot(x, y) plt.title(r'$\sin(2 \pi x)$') # the `r` before the string indicates a "raw string"; plt.plot(x, y, '-r') # solid red line ('r' comes from RGB color scheme) plt.xlim(0, 10) plt.ylim(-1.2, 1.2) plt.xlabel('this is x!') plt.ylabel('this is y!') plt.title('My First Plot'); plt.plot? x = np.linspace(0, 20, 1000) y1 = np.sin(x) y2 = np.cos(x) plt.plot(x, y1, '-b', label='sine') plt.plot(x, y2, '-r', label='cosine') plt.legend(loc='upper right') plt.ylim(-1.5, 2.0); x1 = np.linspace(0, 10, 20) y1 = np.sin(x1) x2 = np.linspace(0, 10, 1000) y2 = np.sin(x2)