# Vertical band plot in makie

**URL:** <https://discourse.julialang.org/t/vertical-band-plot-in-makie/121920>\
**Category:** Visualization\
**Tags:** makie\
**Created:** [October 29, 2024, 2:46pm UTC](https://discourse.julialang.org/t/vertical-band-plot-in-makie/121920 "2024-10-29T14:46:55Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@aris](https://discourse.julialang.org/u/aris)\
**Post date:** [October 29, 2024, 2:46pm UTC](https://discourse.julialang.org/t/vertical-band-plot-in-makie/121920/1 "2024-10-29T14:46:55Z")

</div>

In makie, we can create a [band plot](https://docs.makie.org/dev/reference/plots/band) 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](https://docs.makie.org/dev/reference/plots/violin)?

---

<div class="post-metadata">

**Author:** ![JonasWickman](https://avatars.discourse-cdn.com/v4/letter/j/9de0a6/32.png) [@JonasWickman](https://discourse.julialang.org/u/JonasWickman)\
**Post date:** [October 29, 2024, 3:48pm UTC](https://discourse.julialang.org/t/vertical-band-plot-in-makie/121920/2 "2024-10-29T15:48:25Z")

</div>

The answer from this thread ([How to exchange x and y axis in band plot](https://discourse.julialang.org/t/how-to-exchange-x-and-y-axis-in-band-plot/104090)) seems to still work. That is to say, since it’s not marked as the solution,

> [@How to exchange x and y axis in band plot](https://discourse.julialang.org/t/how-to-exchange-x-and-y-axis-in-band-plot/104090/4):
>
> You can currently use the form with two point arrays like band(Point2f.(xs1, ys), Point2f.(xs2, ys))

---

<div class="post-metadata">

**Author:** ![aris](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@aris](https://discourse.julialang.org/u/aris)\
**Post date:** [October 29, 2024, 4:03pm UTC](https://discourse.julialang.org/t/vertical-band-plot-in-makie/121920/3 "2024-10-29T16:03:58Z")

</div>

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

While we’re at it :

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

```

works perfectly well, but

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

```

throws the following:

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

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [October 29, 2024, 4:08pm UTC](https://discourse.julialang.org/t/vertical-band-plot-in-makie/121920/4 "2024-10-29T16:08:55Z")

</div>

Looks like a bug to me, file an issue?

---

<div class="post-metadata">

**Author:** ![aris](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@aris](https://discourse.julialang.org/u/aris)\
**Post date:** [October 29, 2024, 4:16pm UTC](https://discourse.julialang.org/t/vertical-band-plot-in-makie/121920/5 "2024-10-29T16:16:02Z")

</div>

[Done](https://github.com/MakieOrg/Makie.jl/issues/4543)✅

---

<div class="post-metadata">

**Author:** ![aris](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@aris](https://discourse.julialang.org/u/aris)\
**Post date:** [November 6, 2024, 2:32pm UTC](https://discourse.julialang.org/t/vertical-band-plot-in-makie/121920/6 "2024-11-06T14:32:47Z")

</div>

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

> [@aris](#):
>
> `band!(x, y1,y2 , colormap=:viridis, colorrange=(1, 10), color=5)`

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?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [November 6, 2024, 2:49pm UTC](https://discourse.julialang.org/t/vertical-band-plot-in-makie/121920/7 "2024-11-06T14:49:31Z")

</div>

Bit roundabout but this is one option

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

---

<div class="post-metadata">

**Author:** ![aris](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@aris](https://discourse.julialang.org/u/aris)\
**Post date:** [November 6, 2024, 2:55pm UTC](https://discourse.julialang.org/t/vertical-band-plot-in-makie/121920/8 "2024-11-06T14:55:07Z")

</div>

Does the job, thanks a lot!

---

<div class="post-metadata">

**Author:** ![aris](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@aris](https://discourse.julialang.org/u/aris)\
**Post date:** [June 3, 2025, 12:13pm UTC](https://discourse.julialang.org/t/vertical-band-plot-in-makie/121920/9 "2025-06-03T12:13:25Z")

</div>

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

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

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

```

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [June 3, 2025, 12:28pm UTC](https://discourse.julialang.org/t/vertical-band-plot-in-makie/121920/10 "2025-06-03T12:28:34Z")

</div>

It has another positional argument `interpolate::Bool` now

---

<div class="post-metadata">

**Author:** ![aris](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@aris](https://discourse.julialang.org/u/aris)\
**Post date:** [June 3, 2025, 12:29pm UTC](https://discourse.julialang.org/t/vertical-band-plot-in-makie/121920/11 "2025-06-03T12:29:27Z")

</div>

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.

> [@aris](#):
>
> band!(x, y1,y2 , colormap=:viridis, colorrange=(1, 10), color=5)

We might want to close the [relevant issue](https://github.com/MakieOrg/Makie.jl/issues/4543) if you could also confirm it’s now resolved.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [June 3, 2025, 2:37pm UTC](https://discourse.julialang.org/t/vertical-band-plot-in-makie/121920/12 "2025-06-03T14:37:15Z")

</div>

yup, closed it
