import matplotlib.pyplot as plt import numpy as np x = np.linspace(0, 10, 100) fig, ax = plt.subplots() for i in range(1, 6): ax.plot(x, i*x + x, label='$y={i}x + {i}$'.format(i=i)) ax.legend(loc='upper left') plt.show()