# Groupedbar plotting not as expected

**URL:** <https://discourse.julialang.org/t/groupedbar-plotting-not-as-expected/95545>\
**Category:** Visualization\
**Created:** [March 4, 2023, 3:28pm UTC](https://discourse.julialang.org/t/groupedbar-plotting-not-as-expected/95545 "2023-03-04T15:28:49Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [March 4, 2023, 5:42pm UTC](https://discourse.julialang.org/t/groupedbar-plotting-not-as-expected/95545/4 "2023-03-04T17:42:14Z")

</div>

> [@StatPlots groupedbar order x axis](https://discourse.julialang.org/t/statplots-groupedbar-order-x-axis/13912/18):
>
> Hi, so I just figured out how to do it after a lot of digging. The issue is that in RecipesPipeline.jl there is group\_labels = sort(collect(unique(v))) Now in theory there are CategoricalArrays for this purpose, however unique(ctg::CategoricalArray) returns an ordinary Vector{String} instead of a new CategoricalArray. Defining this solves the problem in this case function Base.unique(ctg::CategoricalArray) l = levels(ctg) newctg = CategoricalArray(l) levels!(newctg, l) end c…

---

_[View the full topic](https://discourse.julialang.org/t/groupedbar-plotting-not-as-expected/95545)._
