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

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?

line_z = a'

1 Like

Thank you!

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