Makie scatter and errorbar combine in legend?

Since errorbar does not take marker option, in order to make a plot the documentation recommend something like:

errorbars!(xs, ys, higherrors, color = :red) # same low and high error

# plot position scatters so low and high errors can be discriminated
scatter!(xs, ys, markersize = 3, color = :black)

However, if you then try to have legend for this item, it looks like:

Is there a way to combine them in the legend without manually creating a Legend() item?

thanks to @aplavin

axislegend(merge=true)

2 Likes

I actually realized this is not what I wanted, because the error bar should be vertical.

For example, this looks wrong:

stairs([1,3,2,1]; label="x")
errorbars!((2:4) .- 0.5, [3,2,1], [2,3,4]; label="x")

axislegend()
current_figure()

with merge=true
image

I suppose one can do this manually: Makie errorbars in legend look awkward - #2 by jules

You can now use legend overrides for this, although there’s still a bug with label merging in this case I think, where it doesn’t associate the same label with different overrides applied

1 Like

Yes merge=true just merges what it has, doesn’t change how entries look.
I also use rangebars/errorbars quite often (not as often as @jling probably :slight_smile: ), at some point was looking into the code trying to find how to fix legend entries for them. But didn’t really manage to do that. Maybe @jling will have more luck?..