I'm trying to plot a graph and color the lines between points based on their slope. The points on my graph only consist of positive values between $0$ and $9$ for both the $X$ and $Y$ axis.
The only thing I can think of is to multiply the result of the slope calculation by some constant value. Unfortunately, this only seems to be giving me a few distinct colors.
Does anyone know of a better way to go about this?

Are you using a step-size for $x$-coordinate? The amount $d$ you increase $x_0$ and then draw the line from $(x_0, f(x_0))$ to $(x_0+d, f(x_0+d))$.
In this case the slope can be between $-\frac{9}{d}$ and $\frac{9}{d}$. You can map it to be a fraction on the interval $[0, 1]$ with the function
$$g(s) = \frac{d}{18} (s+\frac{9}{d})$$
Then it is easy to apply this percentage $t = g(s)$ to get the color. For example, if you want to vary from blue (small values) to red (high values), take the interpolation
$$t(0, 0, 255) + (1-t)(255, 0, 0)$$
I made a little JSFiddle, where this can be tried out. (sMin and sMax are the limits for the slope value). Oops, I made it from red to blue, but that's easy to fix by changing the interpolation end colors to what ever you actually want.