It is not quite clear to me what you want to do. Do you want to:
- Plot, say, 3 curves, with different color, e.g., one red, one blue, and one green?, or
- Do you want to plot one curve which changes color from, say, red to blue, along the curve?
Case 1.a: Julia v. 0.6.x allowed to make a vector of colors using the linspace()
function, something along linspace(colorant"red",colorant"blue",5)
would make a vector of 5 colors in the range from color colorant"red"
and color colorant"blue"
.
Unfortunately, function linspace()
has been removed, and the replacement, range()
doesn’t support color argument. This is really unfortunate!
Anyway, the Plots
syntax is that colors should be a row matrix, so colors in a vector need to be converted to colors in a row matrix.
You can, of course, still make the row matrix of colors manually:
plot([sin,cos,atanh], lc=[:red :blue])
Here, the list of functions will cycle through the row matrix of line colors.
Case 1.b: colors from color gradient.
Use a built-in color gradient, or design your own. Say you want to make your own, my_cgrad
…
my_cgrad = cgrad([:red, :yellow, :blue])
makes a color gradient that starts in red, goes through yellow and ends up in blue. You need a minimum of two color elements in the argument vector.
To pick plot colors from the color gradient, do the following:
plot([sin, cos, atanh], palette = my_cgrad)
Case 2: Suppose you instead want to change the color along the line – perhaps mainly useful in parametric plots. This can be done as follows:
x = range(0,stop=2pi,length=50)
plot(sin.(x),cos.(x),lc=my_cgrad,line_z=x)