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

x = np.linspace(-1, 2, 5)
y1 = 2*x + 1
y2 = x**2

plt.xlim((-1, 2))
plt.ylim((-3, 3))
plt.xlabel('I am x')
plt.ylabel('I am y')

plt.xticks(np.linspace(-2, 2, 5))

plt.yticks([-2,-1,0,1,2], ['$sum_{i=1}^N\sin(x)$','test2','test3','test4','test5'])

#gca  get current axis
ax = plt.gca()
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
plt.grid()


l1, = plt.plot(x, y1, label='up')
l2, = plt.plot(x, y2, color = 'red', linewidth = 1, linestyle='--', label='down')
plt.legend(loc='best')


Out[12]:
<matplotlib.legend.Legend at 0xaf9597d0>