Vertical band plot in makie

In makie, we can create a band plot between two arrays y_lower and y_upper, for a single x array.

Would there be a way to use two x arrays and one y array instead, and produce something that looks more like a violin plot?

The answer from this thread (How to exchange x and y axis in band plot) seems to still work. That is to say, since it’s not marked as the solution,

1 Like

Perfect, that does the job!
Somehow I missed it when I was looking for relevant posts.

While we’re at it :

lines!(x, y , colormap=:viridis, colorrange=(1, 10), color=5)

works perfectly well, but

band!(x, y1,y2 , colormap=:viridis, colorrange=(1, 10), color=5)

throws the following:

TypeError: in typeassert, expected ColorTypes.RGBA{Float32}, got a value of type Float32

Is there something I’m missing here, or is it a bug?

Looks like a bug to me, file an issue?

1 Like

Done :white_check_mark:

Sorry to bring this up again, but would there be a way to achieve this

before the bug is fixed?

Like, maybe we could convert the information in colormap=:viridis, colorrange=(1, 10), color=5 into an RGBA object or equivalent?

Bit roundabout but this is one option

only(Makie.numbers_to_colors([5], Makie.to_colormap(:plasma), identity, Vec2(1, 10), Makie.automatic, Makie.automatic, RGBAf(0, 0, 0, 0)))

For some reason just passing 5 doesn’t work for me even though it should

1 Like

Does the job, thanks a lot!

Sorry for necroposting, but after a recent update this method seems to be broken.

ERROR: MethodError: no method matching numbers_to_colors(::Vector{…}, ::Vector{…}, ::typeof(identity), ::Vec{…}, ::MakieCore.Automatic, ::MakieCore.Automatic, ::ColorTypes.RGBA{…})
The function `numbers_to_colors` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  numbers_to_colors(::Union{Number, AbstractArray{<:Number, N}}, ::Any, ::Any, ::Vec2, ::Union{MakieCore.Automatic, ColorTypes.RGBA{Float32}}, ::Union{MakieCore.Automatic, ColorTypes.RGBA{Float32}}, ::ColorTypes.RGBA{Float32}, ::Any) where N
   @ Makie ~/.julia/packages/Makie/dYDv2/src/colorsampler.jl:168
  numbers_to_colors(::Union{Number, AbstractArray{<:Number}}, ::Any)
   @ Makie ~/.julia/packages/Makie/dYDv2/src/colorsampler.jl:149

Stacktrace:
 [1] top-level scope
   @ REPL[4]:1
Some type information was truncated. Use `show(err)` to see complete types.

It has another positional argument interpolate::Bool now

1 Like

Thanks for the update. Since I’m using this in a package, is there a more stable equivalent by any chance?
Update: it seems that band() accepts these arguments without an issue now.

We might want to close the relevant issue if you could also confirm it’s now resolved.

yup, closed it

1 Like