Alpha vs color

In this answer there is

band!(x_plot, mea .- st3, mea .+ st3, color = (:blue, 0.2))

which makes a transparent band

but using alpha explicitly doesn’t

band!(x_plot, mea .- st3, mea .+ st3, color = :blue, alpha=0.2)

  • Is the Tuple{Symbol, Number} form of color= documented?
  • Why doesn’t alpha= work here?

Good question if it’s documented, I’m not sure if or where, but basically Makie never uses alpha keywords. You always have to pass colors with alpha channel if you want transparency, and the tuple syntax has a conversion overload to RGBA.

The only problem is that alpha can mean something slightly different, that is an opacity value for one whole layer of drawing operations together. You can’t copy that by assigning each element a half transparent color, think about the stroke and fill of a scatter for example. And Makie doesn’t implement this “layer opacity” at all.

1 Like

Shouldn’t it issue a warning then? Like

`alpha` keyword is not supported by Makie. Use `color = (:color, alpha)` instead
1 Like

Fwiw alpha and transparency both appear at http://makie.juliaplots.org/stable/generated/plot-attributes.html.

1 Like

How do I set the alpha while retaining the ability to autocycle through the color palette? E.g. when doing

lines(rand(10))
lines!(rand(10))
current_figure()

the lines will automatically have colors 1 and 2 from the currently chosen palette. If to set the alpha value I need to to

lines(rand(10), color = (:blue, 0.5))
lines!(rand(10), color = (:orange, 0.5))
current_figure()

I lose the ability to automatically take from the color palette and need to manually specify colors for each line.

Hm yeah without an alpha keyword that’s difficult. You could set a palette with alpha maybe? Using Colors.coloralpha for example