In [1]:
import numpy as np
import matplotlib.pyplot as plt
In [2]:
# y = mx + b

x = [-5,5]
m = -.3
b = .1

#y = [0, 0]
#for i in range(0,len(x)):
#    y[i] = m*x[i] + b
#print(x,y)

y = m*np.array(x) + b

plt.plot(x,y,label='y=%s+%s' %(m,b))

plt.axis('square')
plt.grid()
plt.xlim(x)
plt.ylim(x)

axis = plt.gca() # get current axis
plt.plot(axis.get_xlim(),[0,0],'k--')
plt.plot([0,0],axis.get_ylim(),'k--')

plt.legend()

plt.show()
In [3]:
x = [-5,5]
m = [.7,-1.25]
b = [-2,.75]

for i in range(0,len(m)):
    y = m[i]*np.array(x)+b[i]
    plt.plot(x,y,label='y = %sx + %s' %(m[i],b[i]))
    
    
plt.axis('square')
plt.grid()
plt.xlim(x)
plt.ylim(x)

axis = plt.gca() # get current axis
plt.plot(axis.get_xlim(),[0,0],'k--')
plt.plot([0,0],axis.get_ylim(),'k--')

plt.legend()
plt.show()