Makie: Color and theme for errorbars

Hi, I have two questions about errorbars in Makie. Consider the following example:

using CairoMakie

set_theme!(Theme(
    Lines=(linewidth = 4,),
    ErrorBars=(linewidth = 4,)
))

x = [1, 2, 3, 4, 5]

y_A = [1, 2, 1, 2, 1]
err_A = [0.1, 0.2, 0.1, 0.2, 0.3]

y_B = [2, 3, 2, 3, 2]
err_B = [0.2, 0.3, 0.2, 0.1, 0.1]

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

lines!(ax, x, y_A, label='A')
errorbars!(ax, x, y_A, err_A, label='A')

lines!(ax, x, y_B, label='B')
errorbars!(ax, x, y_B, err_B, label='B')

f

It produces this figure:

Question 1: I would like to have the color of the errorbars match the color of the corresponding lines. Is this possible?

Question2: Notice that the linewidth settings from the Theme is ignored for the errorbars. Is this a bug or did I get it wrong?

Thanks!

Do

set_theme!(Theme(
    Lines=(linewidth = 4,),
    Errorbars=(linewidth = 4, cycle=[:color])
))

and it should work.
Your mistake was the capital B in ErrorBars.
To cycle colors for Errorbars, you can use the cycle attribute as further explained here Page Redirection

2 Likes

Thank you, Filippos! Works perfectly.

We could think about making that part of the default theme, too

1 Like