Makie errorbars in legend look awkward

Hi,
somehow I cannot find the solution to this problem online.
I want a simple plot with errorbars which are shown in the legend:

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

errorbars!(ax,1:10,rand(10),0.05*ones(10),color = :black,whiskerwidth = 12,label = "errors")
axislegend(ax)
fig

produces this plot:

The legend looks quite off, one cannot see that these symbols are actually errorbars, it looks more like a line.
Does anyone know how to do this properly?

it looks more like a line

It is a line :slight_smile:

errorbars has no specific legend overload so it just shows the one for the underlying lines. One could build a better one in principle, for example:

f = Figure()
Legend(f[1, 1], [[
    LineElement(linepoints = [Point2f(0.5, 0), Point2f(0.5, 1)]),
    MarkerElement(points = [Point2f(0.5, 0), Point2f(0.5, 1)], marker = :hline, markersize = 10),
]], ["errorbar"])
f

image

1 Like

Ah thank you, I see.
Is there a specific reason for why there is no such overload or can one attempt a PR to change this?

No specific reason. I guess I didn’t want to deal with the caps and updating it correctly depending on errorbar direction.

1 Like