LucasV
August 25, 2025, 3:58am
1
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:
#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
Is there any workaround for this problem? Didn’t find any related topic for this issue
Try this:
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
)
LucasV
August 25, 2025, 12:56pm
3
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.
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
That is a different question and a different bug, which was reported here .
A workaround for the 2nd bug is:
plot!(xlims=(0,5))