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

**URL:** <https://discourse.julialang.org/t/how-to-use-a-color-gradient-when-plotting-different-functions-in-the-same-plot/22117>\
**Category:** Visualization\
**Tags:** first-steps\
**Created:** [March 20, 2019, 6:27pm UTC](https://discourse.julialang.org/t/how-to-use-a-color-gradient-when-plotting-different-functions-in-the-same-plot/22117 "2019-03-20T18:27:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![drarnau](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/drarnau/32/4476_2.png) [@drarnau](https://discourse.julialang.org/u/drarnau)\
**Post date:** [March 20, 2019, 6:27pm UTC](https://discourse.julialang.org/t/how-to-use-a-color-gradient-when-plotting-different-functions-in-the-same-plot/22117/1 "2019-03-20T18:27:22Z")

</div>

I have tried something like

```julia
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?

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [March 22, 2019, 11:32am UTC](https://discourse.julialang.org/t/how-to-use-a-color-gradient-when-plotting-different-functions-in-the-same-plot/22117/2 "2019-03-22T11:32:10Z")

</div>

`line_z = a'`

---

<div class="post-metadata">

**Author:** ![drarnau](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/drarnau/32/4476_2.png) [@drarnau](https://discourse.julialang.org/u/drarnau)\
**Post date:** [March 22, 2019, 1:01pm UTC](https://discourse.julialang.org/t/how-to-use-a-color-gradient-when-plotting-different-functions-in-the-same-plot/22117/3 "2019-03-22T13:01:59Z")

</div>

Thank you!

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

```
