How to use a color gradient when plotting different functions in the same plot?

first-steps
#1

I have tried something like

plot()
for a = 1:5
    f(x) = x^a
     plot!(f, -5, 5, palette = cgrad(:viridis))
end
plot!()

What I am looking for is that the colours of each plot reflect the idea that a increases. For example, if I choose a colour scheme that works with blues, I’d like to start with a very light blue for a=1 and have a much darker blue when a=5.

Any ideas on how to do it?

0 Likes

#2

line_z = a'

1 Like

#3

Thank you!

plot()
for a = 1:5
    f(x) = x^a
    plot!(f, -5, 5, palette = cgrad(:viridis), line_z = a')
end
plot!()
0 Likes