Horizontal bar plots with error bars

I am trying to make a horizontal bar plot with error bars, but I am having issues:

using Plots, Distributions
labels = ["aaa","bbb","ccc"]
values = [10,8,7]
sd     = [2.2,0.8,1.5]
n      = 30
errors = quantile(Normal(0,1),0.975) .* sd ./ sqrt(30)
  • Vertical bars plot with error bars: this work normally…
bar(labels,values,yerror=errors)

plot1

  • Horizontal bars plot: this somehow works, even if it leaves extra space (eventually with yflip=true we leave the empty space in the bottom)…
bar(values, orientation=:h, yticks=(1:length(labels),labels))

plot2

  • Horizontal bars plot with error bars. This is completely messed up (I have tried also with yerrors)…
bar(values, orientation=:h, yticks=(1:length(labels),labels),xerror=sd)

plot3

orientation is deprecated, please use permute - see bug report here.

2 Likes

Thanks, this works:

bar(labels, values, permute=(:x,:y), yerror=errors)
plot4