# Alpha keyword ignored in scatterlines

**URL:** <https://discourse.julialang.org/t/alpha-keyword-ignored-in-scatterlines/116954>\
**Category:** Visualization\
**Tags:** makie, cairo, cairomakie-plotting, cairomakie\
**Created:** [July 12, 2024, 8:57am UTC](https://discourse.julialang.org/t/alpha-keyword-ignored-in-scatterlines/116954 "2024-07-12T08:57:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![AtomsForHire](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@AtomsForHire](https://discourse.julialang.org/u/AtomsForHire)\
**Post date:** [July 12, 2024, 8:57am UTC](https://discourse.julialang.org/t/alpha-keyword-ignored-in-scatterlines/116954/1 "2024-07-12T08:57:30Z")

</div>

MWE:

```julia
using CairoMakie

set_theme!(theme_latexfonts())
update_theme!(
    palette=(color=ColorSchemes.glasbey_category10_n256.colors,),
    ScatterLines=(cycle=Cycle(:color),)
)

function main()
    f = Figure()
    ax = Axis(f[1, 1])

    for i in 1:1
        scatterlines!(ax, 0:127, rand(128), label=string(i), alpha=0.5)
        lines!(ax, 0:127, rand(128), label=string(i), alpha=0.5)
    end

    Legend(f[1, 2], ax, "Some Title", framevisible=false)
    ax.xlabel = "x-axis"
    ax.ylabel = "y-axis"

    resize_to_layout!(f)
    display(f)
end

main()

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/a/1/a1031727bfdf01fc145d16b2d1a43c08e64de184.png)

It seems like the alpha keyword is possibly ignored in `scatterlines`? Or perhaps I am doing something wrong again. The same thing happens in a fresh julia session after commenting out the lines to do with theming.

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [July 12, 2024, 9:34am UTC](https://discourse.julialang.org/t/alpha-keyword-ignored-in-scatterlines/116954/2 "2024-07-12T09:34:19Z")

</div>

It’s always good to take the “M” in MWE seriously to make life easy for others. In this case you probably want:

```julia
scatterlines(rand(10); alpha = 0.1)

```

which indeed doesn’t work. There’s a bit of `alpha` whack-a-mole in the Makie repo:

> <https://github.com/MakieOrg/Makie.jl/issues/3099>
>
> First of all, thank you for landing support for the \`alpha\` keyword in Makie! :t…ada: I am enjoying that feature quite a lot!
> 
> I found what seems to be an edge case with that feature: \`Makie.boxplot\` seems to ignore this keyword (at least in GLMakie).
> 
> \`\`\`julia
> using GLMakie
> 
> data = rand(100)
> boxplot(ones(length(data)), data; color = :black, alpha = 0.5)
> \`\`\`
> !\[image\](https://github.com/MakieOrg/Makie.jl/assets/10076790/bb32c981-737e-4eac-875a-7f42e19cf213)
> 
> Expected result:
> \`\`\`julia
> boxplot(ones(length(data)), data; color = (:black,0.5))
> \`\`\`
> 
> !\[image\](https://github.com/MakieOrg/Makie.jl/assets/10076790/43c0b070-0f5e-49d7-adf5-1d853e31fb77)

> <https://github.com/MakieOrg/Makie.jl/issues/3356>
>
> \`\`\`julia
> f = Figure()
> ax1 = Axis(f\[1, 1\], title="alpha = 0.5")
> ax…2 = Axis(f\[1, 2\], title="color = (:red, 0.5)")
> xs = 1:10
> lower, upper = fill(-1.0, 10), fill(1.0, 10)
> band!(ax1, xs, lower, upper, color=:red, alpha=0.5)
> band!(ax2, xs, lower, upper, color=(:red, 0.5))
> \`\`\`
> 
> !\[makie\_issue\](https://github.com/MakieOrg/Makie.jl/assets/39778698/702ed9e0-7a70-4e43-9112-694f737c6d6d)

> <https://github.com/MakieOrg/Makie.jl/issues/3466>
>
> I am often in the situation where I just want to add some alpha (transparency) t…o a plot, without making changes to colors. So I would like to use the default colours, or one specified with \`Cycled\`, but with some alpha != 1.. However, I have been unable to find a way to do this without manually specifying a color.
> 
> Perhaps it would be feasable to add field "alpha" to \`Cycled\`? It could then be \`Cycled(1, 0.5)\`, analogus to \`(:black, 0.5)\`.

> <https://github.com/MakieOrg/Makie.jl/issues/3903>
>
> On GLMakie 0.9 with Makie 0.20, \`hist(rand(100); alpha = 0.5)\` produces a histog…ram with opaque bars. 
> 
> On GLMakie 0.10 with Makie 0.21 I get:
> 
> \`\`\`
> Invalid attribute alpha for plot type Plot{Makie.hist}.
> 
> The available plot attributes for Plot{Makie.hist} are:
> 
> bar\_labels fillto label\_formatter over\_background\_color weights
> bins flip\_labels\_at label\_offset over\_bar\_color                
> color gap label\_size scale\_to                      
> cycle label\_color normalization strokecolor                   
> direction label\_font offset strokewidth   
> \`\`\`

So feel free to add your issue I guess? Maybe @jules @sdanisch have other plans on how to deal with this more generally?

---

<div class="post-metadata">

**Author:** ![AtomsForHire](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@AtomsForHire](https://discourse.julialang.org/u/AtomsForHire)\
**Post date:** [July 12, 2024, 1:31pm UTC](https://discourse.julialang.org/t/alpha-keyword-ignored-in-scatterlines/116954/3 "2024-07-12T13:31:38Z")

</div>

Thanks for the tip, I’ll have to remind myself what minimal means lol. Unfortunate to see this is an issue in other parts of Makie as well

---

<div class="post-metadata">

**Author:** ![fgerick](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fgerick/32/13228_2.png) [@fgerick](https://discourse.julialang.org/u/fgerick)\
**Post date:** [July 12, 2024, 2:19pm UTC](https://discourse.julialang.org/t/alpha-keyword-ignored-in-scatterlines/116954/4 "2024-07-12T14:19:56Z")

</div>

I think you can use

```julia
scatterlines(rand(10), color=(Makie.wong_colors()[1],0.5))

```

Unfortunately, you cannot use `color=(Cycled(1),0.5)`, but I think there was an issue already opened for this.

---

<div class="post-metadata">

**Author:** ![AtomsForHire](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@AtomsForHire](https://discourse.julialang.org/u/AtomsForHire)\
**Post date:** [July 15, 2024, 2:52am UTC](https://discourse.julialang.org/t/alpha-keyword-ignored-in-scatterlines/116954/5 "2024-07-15T02:52:11Z")

</div>

Thank you, your suggestion works well! I was able to use it with `ColorSchemes.glasbey_category10_n256.colors[i], 0.7`
