# How to give proper order in xaxis during boxplot?

**URL:** <https://discourse.julialang.org/t/how-to-give-proper-order-in-xaxis-during-boxplot/99206>\
**Category:** New to Julia\
**Tags:** question, plotting\
**Created:** [May 22, 2023, 8:52am UTC](https://discourse.julialang.org/t/how-to-give-proper-order-in-xaxis-during-boxplot/99206 "2023-05-22T08:52:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sahil\_Khan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sahil_khan/32/47573_2.png) [@Sahil\_Khan](https://discourse.julialang.org/u/Sahil_Khan)\
**Post date:** [May 22, 2023, 8:52am UTC](https://discourse.julialang.org/t/how-to-give-proper-order-in-xaxis-during-boxplot/99206/1 "2023-05-22T08:52:31Z")

</div>

How to arrange it as P9, P10 and P11?

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

---

<div class="post-metadata">

**Author:** ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)\
**Post date:** [May 22, 2023, 9:18am UTC](https://discourse.julialang.org/t/how-to-give-proper-order-in-xaxis-during-boxplot/99206/2 "2023-05-22T09:18:19Z")

</div>

Can you give a complete example? (In particular it’s not clear which plotting package you’re using).

---

<div class="post-metadata">

**Author:** ![Sahil\_Khan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sahil_khan/32/47573_2.png) [@Sahil\_Khan](https://discourse.julialang.org/u/Sahil_Khan)\
**Post date:** [May 22, 2023, 9:25am UTC](https://discourse.julialang.org/t/how-to-give-proper-order-in-xaxis-during-boxplot/99206/3 "2023-05-22T09:25:25Z")

</div>

In this example I will expect it to be P13, P12, P11, P10 but its giving P10, P11, P12, P13

```julia
using StatsPlots, DataFrames

x = repeat(["P13", "P12", "P11", "P10"], inner = 4, outer = 3)
y = [1,2,3,4,5,6,7,8,9,10,10,2,12,4,1,2,1,2,3,4,5,6,7,8,9,10,10,2,12,4,1,2, 1,2,3,4,5,6,7,8,9,10,10,2,12,4,1,2]
df = DataFrame(x=x, y=y)
@df df boxplot(:x, :y)

```

---

<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:** [May 22, 2023, 9:32am UTC](https://discourse.julialang.org/t/how-to-give-proper-order-in-xaxis-during-boxplot/99206/4 "2023-05-22T09:32:12Z")

</div>

> [@How to adjust the X-axis order of boxplot with StatsPlots.jl](https://discourse.julialang.org/t/how-to-adjust-the-x-axis-order-of-boxplot-with-statsplots-jl/56065/9):
>
> Hi, @mkborregaard, I have no knowledge of internal details. But how about @df df boxplot(string.(:id), :value, fillalpha=0.75, linewidth=1, xorder=[3, 17, 21]) Or we may pass into a custom sort function to sort the specific column in a df. @df df boxplot(string.(:id), :value, fillalpha=0.75, linewidth=1, xsort=sort) The above two lpad and sprintf workarounds work well for this particular example. But what if I want the order to be 21 3 17? Of course, I can still fi…

---

<div class="post-metadata">

**Author:** ![Sahil\_Khan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sahil_khan/32/47573_2.png) [@Sahil\_Khan](https://discourse.julialang.org/u/Sahil_Khan)\
**Post date:** [May 22, 2023, 9:38am UTC](https://discourse.julialang.org/t/how-to-give-proper-order-in-xaxis-during-boxplot/99206/5 "2023-05-22T09:38:42Z")

</div>

Isn’t there any internal attribute for same?
