JuliaPlots / StatsPlots.jl

Statistical plotting recipes for Plots.jl
Other
437 stars 88 forks source link

Annotation in bars #521

Open alfaromartino opened 2 years ago

alfaromartino commented 2 years ago

I wasn't sure if I should post this here or StatsPlots, but this issue is the same as in JuliaPlots/Plots.jl#3574. If you add numbers to each bar in groupedbar, it always repeats the numbers of the first group. The error was reproduced in pgfplotsx, pyplot, gr, and plotly as backends.

MWE:

using StatsPlots

x=["A","A","B","B"]
y=[1,2,3,4]
year=["2020","2021","2020","2021"]

groupedbar(x,y,group=year,bar_width=0.7,series_annotations=y)

which gives as result blah

The location of the annotation is also wrong, (which is the same as issue JuliaPlots/Plots.jl#3574). I've been using the following workaround, and the problem is the same.

groupedbar(x,y,group=year,bar_width=0.7)
groupedbar!(x,y./2,group=year,bar_width=0.7,
alpha = 0.0,label="",series_annotations=[1 2 3 4],legend=:outertopright)

which gives blah2