matplotlib

We will uise matplotlib to use graphs. It has we organized documentation here.


In [15]:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

plot


In [24]:
x = np.arange(0, 2* np.pi, 0.1)
plt.plot(x, np.sin(x))
plt.plot(x, np.cos(x))
plt.xlabel('x')
plt.ylabel('y')
plt.title('Sine and Cosine')
plt.legend(['sin','cos'])
plt.show()


subplot


In [31]:
x = np.arange(0, 2* np.pi, 0.1)

plt.subplot(2,1,1)
plt.plot(x, np.sin(x))
plt.title('Sine and Cosine')
plt.ylabel('y')
plt.subplot(2,1,2)
plt.plot(x, np.cos(x),'|')
plt.xlabel('x')
plt.ylabel('y')
plt.show()


image


In [32]:
img = np.random.random((100,100))

In [33]:
plt.imshow(img)


Out[33]:
<matplotlib.image.AxesImage at 0x7fbbdc3bb390>

In [38]:
plt.hist(np.random.beta(2,2,10000),bins=100);



In [ ]: