# Plot horizontal error bars in Gadfly or Plots.jl

**URL:** <https://discourse.julialang.org/t/plot-horizontal-error-bars-in-gadfly-or-plots-jl/3216>\
**Category:** General Usage\
**Created:** [April 14, 2017, 2:54pm UTC](https://discourse.julialang.org/t/plot-horizontal-error-bars-in-gadfly-or-plots-jl/3216 "2017-04-14T14:54:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Post date:** [April 14, 2017, 2:54pm UTC](https://discourse.julialang.org/t/plot-horizontal-error-bars-in-gadfly-or-plots-jl/3216/1 "2017-04-14T14:54:14Z")

</div>

I was wondering if it is possible to plot horizontal error bars with category labels on the y axis. I attached an example of what I would like to accomplish.

Thanks,

Chris

 ![](https://global.discourse-cdn.com/julialang/original/3X/4/b/4bb897cc6d5583e6f777429df1cdab2e428fee4e.png)

---

<div class="post-metadata">

**Author:** ![evanfields](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evanfields/32/1744_2.png) [@evanfields](https://discourse.julialang.org/u/evanfields)\
**Post date:** [April 14, 2017, 4:04pm UTC](https://discourse.julialang.org/t/plot-horizontal-error-bars-in-gadfly-or-plots-jl/3216/2 "2017-04-14T16:04:30Z")

</div>

This can be done in Gadfly using `Geom.errorbar` (see [here](http://gadflyjl.org/stable/lib/geoms/geom_errorbar.html#Geom.errorbar-1))

```julia
julia> using Gadfly

julia> x = sort(rand(10)); xmin = 0.9x; xmax = 1.1x;

julia> ystr = map(i -> string(i) * " as a string", 1:10)
10-element Array{String,1}:
 "1 as a string"
 "2 as a string"
 "3 as a string"
 "4 as a string"
 "5 as a string"
 "6 as a string"
 "7 as a string"
 "8 as a string"
 "9 as a string"
 "10 as a string"

julia> plot(y = ystr, x = x, xmin = xmin, xmax = xmax, Geom.errorbar)

julia> draw(PNG("C:\\Users\\Evan\\Desktop\\heb.png",8inch,6inch),ans)

```

gives

 ![](https://global.discourse-cdn.com/julialang/original/3X/a/d/adc1795ffd40a9a1ae682057cd2e528d1fe25336.png)  
I expect other plotting packages can do it as well, I just can’t say since I don’t use them.

---

<div class="post-metadata">

**Author:** ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Post date:** [April 14, 2017, 4:17pm UTC](https://discourse.julialang.org/t/plot-horizontal-error-bars-in-gadfly-or-plots-jl/3216/3 "2017-04-14T16:17:40Z")

</div>

Thanks @evanfields. This was easier than I thought.
