O'Reilly logo
  • Ryan Dahlke thinks this is interesting:

Let's demonstrate a simple plotting functionality of the IPython Notebook. In a new cell, paste the following code:

import numpy as np
import math
import matplotlib.pyplot as plt

x = np.linspace(0, 2*math.pi) 
plt.plot(x, np.sin(x), label=r'$\sin(x)$') 
plt.plot(x, np.cos(x), 'ro', label=r'$\cos(x)$') 
plt.title(r'Two plots in a graph') 
plt.legend() 

From

Cover of Mastering Python for Finance

Note

If you receive an error regarding matplotlib displaying the output, you might want to try to include a
%matplotlib inline
at the top of the cell. That fixed an issue for me.