I would like to apply a color gradient to lines based on their slopes. The problem I am having is that the line with the smallest slope is not visible. I tried changing the the values argument for cgrad, but I can’t seem to constrain the range so that the lines are visible. Any help would be appreciated.
MWE
using Plots
linear(x, β0, β1) = β0 + β1 * x
x = range(-2, 2, length=50)
β1s = range(0, 2, length=5)
ys = map(β1 -> linear.(x, 0, β1), β1s)
plot(x, ys, line_z = β1s', colorbar=false, leg=:topleft, color = cgrad(:Purples, .0:.1:.4))
Thank you! I was just about to explore that possibility when I was looking through some examples where a vector of colors was passed. Good to know that is a solution!
Do you know whether passing 0:.1:.4 to cgrad should have constrained the gradient, or am I misunderstanding its function?