# Horizontal bar plots with error bars

**URL:** <https://discourse.julialang.org/t/horizontal-bar-plots-with-error-bars/114217>\
**Category:** Visualization\
**Tags:** plots\
**Created:** [May 14, 2024, 4:28am UTC](https://discourse.julialang.org/t/horizontal-bar-plots-with-error-bars/114217 "2024-05-14T04:28:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [May 14, 2024, 4:28am UTC](https://discourse.julialang.org/t/horizontal-bar-plots-with-error-bars/114217/1 "2024-05-14T04:28:19Z")

</div>

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

```julia
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…

```julia
bar(labels,values,yerror=errors)

```

![plot1](https://global.discourse-cdn.com/julialang/original/3X/a/5/a5da0e9a456819d81bf39e83f5ac96d49b1f7cfd.png)

- Horizontal bars plot: this somehow works, even if it leaves extra space (eventually with `yflip=true` we leave the empty space in the bottom)…

```julia
bar(values, orientation=:h, yticks=(1:length(labels),labels))

```

![plot2](https://global.discourse-cdn.com/julialang/original/3X/c/7/c7215e2c9b92efdb649f5f5ba1a53907c0fdeb90.png)

- Horizontal bars plot with error bars. This is completely messed up (I have tried also with yerrors)…

```julia
bar(values, orientation=:h, yticks=(1:length(labels),labels),xerror=sd)

```

![plot3](https://global.discourse-cdn.com/julialang/original/3X/5/4/544f30c2573157401b620eb33c0a7ca5ae590cdc.png)

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [May 14, 2024, 2:23pm UTC](https://discourse.julialang.org/t/horizontal-bar-plots-with-error-bars/114217/2 "2024-05-14T14:23:05Z")

</div>

`orientation` is deprecated, please use `permute` - see bug report [here](https://github.com/JuliaPlots/Plots.jl/issues/4756#issuecomment-1570823536).

---

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [May 14, 2024, 2:39pm UTC](https://discourse.julialang.org/t/horizontal-bar-plots-with-error-bars/114217/3 "2024-05-14T14:39:00Z")

</div>

Thanks, this works:

`bar(labels, values, permute=(:x,:y), yerror=errors)`  
 ![plot4](https://global.discourse-cdn.com/julialang/original/3X/e/2/e22f065ffeed3d4424b85c09f2d752227a24b0a7.png)
