The slope equation $y=mx+c$ as we know it today is attributed to René Descartes (AD 1596-1650), Father of Analytic Geometry.
The equation $y=mx+c$y=mx+c represents a straight line graphically, where $m$m is its slope/gradient and $c$c its intercept. In this tutorial, you will learn how to plot $y=mx+b$y=mx+b in Python with Matplotlib.
Consider the straight line $y=2x+1$y=2x+1 , whose slope/gradient is $2$2 and intercept is $1$1. Before we plot, we need to import NumPy and use its linspace()
function to create evenly-spaced points in a given interval. In the below example, linspace(-5,5,100)
returns 100 evenly spaced points over the interval [-5,5] and this array of points goes as the first argument of the plot()