# Progressive colormap transparency

**URL:** <https://discourse.julialang.org/t/progressive-colormap-transparency/125194>\
**Category:** General Usage\
**Tags:** makie\
**Created:** [January 25, 2025, 2:09pm UTC](https://discourse.julialang.org/t/progressive-colormap-transparency/125194 "2025-01-25T14:09:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gravlax](https://avatars.discourse-cdn.com/v4/letter/g/dbc845/32.png) [@Gravlax](https://discourse.julialang.org/u/Gravlax)\
**Post date:** [January 25, 2025, 2:09pm UTC](https://discourse.julialang.org/t/progressive-colormap-transparency/125194/1 "2025-01-25T14:09:25Z")

</div>

I was wondering: what is the best way to make a colormap progressively transparent?  
In practice I’d like to use a colormap (e.g. :bilbao) but I’d like the color to progressively become transparent for low values of the range.  
Any hint is welcome!

ps: I’m currently using CairoMakie.

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [January 25, 2025, 2:41pm UTC](https://discourse.julialang.org/t/progressive-colormap-transparency/125194/2 "2025-01-25T14:41:13Z")

</div>

one possibility is [Making colorschemes · ColorSchemeTools](https://juliagraphics.github.io/ColorSchemeTools.jl/latest/makingschemes/#Alpha-opacity-colorschemes)

---

<div class="post-metadata">

**Author:** ![p\_f](https://avatars.discourse-cdn.com/v4/letter/p/45deac/32.png) [@p\_f](https://discourse.julialang.org/u/p_f)\
**Post date:** [January 25, 2025, 3:25pm UTC](https://discourse.julialang.org/t/progressive-colormap-transparency/125194/3 "2025-01-25T15:25:10Z")

</div>

You can construct a vector of `(color,alpha)` pairs for all data points, but the best way to do that is unclear to me. e.g.

```julia
x = 1:100
y = sin.(2*pi .* x ./ 100)

cmap = cgrad(:viridis,length(x),categorical=true)
colors = [(cmap[i],1-i/length(x)) for i in 1:length(x)]
f,ax,s=lines(x,y,color=colors,linewidth=10)

```

but the `cgrad` function seems a bit strange to me, not returning a length of 100 for some colormaps without `categorical=true`?

 ![image](https://global.discourse-cdn.com/julialang/original/3X/4/7/478e94be1f0d1db688d6ee079c25a593ff86a902.png)

there’s also `get(Makie.ColorSchemes.viridis,range(0,1,100))` instead of `cgrad`, but that doesn’t accept symbols for colormaps so seems a bit annoying to use
