# Broken permutation of axis in StatsPlots.jl with error bars

**URL:** https://discourse.julialang.org/t/broken-permutation-of-axis-in-statsplots-jl-with-error-bars/131826
**Category:** Visualization
**Tags:** plotting, bug, statsplots
**Created:** [August 25, 2025, 3:58am UTC](https://discourse.julialang.org/t/broken-permutation-of-axis-in-statsplots-jl-with-error-bars/131826 "2025-08-25T03:58:08Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![LucasV](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lucasv/32/218374_2.png) [@LucasV](https://discourse.julialang.org/u/LucasV)
#### Post date: [August 25, 2025, 3:58am UTC](https://discourse.julialang.org/t/broken-permutation-of-axis-in-statsplots-jl-with-error-bars/131826/1 "2025-08-25T03:58:08Z")

</div>

Hi everyone, recently I’ve tried to plot a grouped bar using StatsPlots.jl with error bars. The plot works fine with no errors but when I insert them it does not work porperly, as shown in the example:

Code:

```julia-auto
#Permutation works
groupedbar(
    ["A", "B", "C", "D"], 
    rand(4,2),
    permute = (:x, :y)
)

#Permutation fails
groupedbar(
    ["A", "B", "C", "D"], 
    rand(4,2),
    yerr = rand(4,2),
    permute = (:x, :y)
)

```

**Second code result**  
 ![plot_38](https://global.discourse-cdn.com/julialang/original/3X/4/2/42393c043fb7682f5011c007b099d92c60d3ab49.svg)

Is there any workaround for this problem? Didn’t find any related topic for this issue

---

<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: [August 25, 2025, 6:20am UTC](https://discourse.julialang.org/t/broken-permutation-of-axis-in-statsplots-jl-with-error-bars/131826/2 "2025-08-25T06:20:44Z")

</div>

> [@LucasV](#):
>
> Is there any workaround for this problem?

Try this:

```julia-auto
data = rand(4,2)
groupedbar(
    ["A", "B", "C", "D"], 
    data,
    permute = (:x, :y),
)
groupedbar!(
    ["A", "B", "C", "D"], 
    data,
    yerr = 0.1*data,
    permute = (:x, :y),
    fillcolor =:transparent
)

```

---

<div class="post-metadata">

### Author: ![LucasV](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lucasv/32/218374_2.png) [@LucasV](https://discourse.julialang.org/u/LucasV)
#### Post date: [August 25, 2025, 12:56pm UTC](https://discourse.julialang.org/t/broken-permutation-of-axis-in-statsplots-jl-with-error-bars/131826/3 "2025-08-25T12:56:46Z")

</div>

Thanks @rafael.guerra, but this solution only solves my problem partially. When you permute the axis, it is not possible to change the limits of the horizontal axis.

```julia-auto
data = rand(4,2)
groupedbar(
    ["A", "B", "C", "D"], 
    data,
    permute = (:x, :y),
)

#This plot gives the same result as
groupedbar!(
    ["A", "B", "C", "D"], 
    data,
    yerr = 0.1*data,
    permute = (:x, :y),
    fillcolor =:transparent,
    xlims = [0,5],
    label = false

#this one
groupedbar!(
    ["A", "B", "C", "D"], 
    data,
    yerr = 0.1*data,
    permute = (:x, :y),
    fillcolor =:transparent,
    ylims = [0,5],
    label = false

```

Notice in both cases we change the yaxis limit and not one or another  
 ![plot_82](https://global.discourse-cdn.com/julialang/original/3X/6/c/6cf7f3ef5cf6dcb50765cd7196eb9e7910cb89d0.svg)

---

<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: [August 25, 2025, 1:35pm UTC](https://discourse.julialang.org/t/broken-permutation-of-axis-in-statsplots-jl-with-error-bars/131826/4 "2025-08-25T13:35:05Z")

</div>

That is a different question and a different bug, which was reported [here](https://github.com/JuliaPlots/StatsPlots.jl/issues/537).

---

<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: [August 25, 2025, 1:37pm UTC](https://discourse.julialang.org/t/broken-permutation-of-axis-in-statsplots-jl-with-error-bars/131826/5 "2025-08-25T13:37:58Z")

</div>

A workaround for the 2nd bug is:

```julia-auto
plot!(xlims=(0,5))

```
