Answers for "how to plot a linear equation in matplotlib"

0

how to plot a linear equation in matplotlib

import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(-5,5,100)
y = 2*x+1
plt.plot(x, y, '-r', label='y=2x+1')
plt.title('Graph of y=2x+1')
plt.xlabel('x', color='#1C2833')
plt.ylabel('y', color='#1C2833')
plt.legend(loc='upper left')
plt.grid()
plt.show()
Posted by: Guest on December-30-2020

Code answers related to "how to plot a linear equation in matplotlib"

Python Answers by Framework

Browse Popular Code Answers by Language