# Makie: categorical x variables

**URL:** https://discourse.julialang.org/t/makie-categorical-x-variables/71263
**Category:** Visualization
**Tags:** plotting, makie
**Created:** [November 10, 2021, 2:45pm UTC](https://discourse.julialang.org/t/makie-categorical-x-variables/71263 "2021-11-10T14:45:33Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![HenriDeh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrideh/32/8316_2.png) [@HenriDeh](https://discourse.julialang.org/u/HenriDeh)
#### Post date: [November 10, 2021, 2:45pm UTC](https://discourse.julialang.org/t/makie-categorical-x-variables/71263/1 "2021-11-10T14:45:33Z")

</div>

Hi,

I recently moved from Plots to Makie and I am trying to make a box plot where each box aggregates data w.r.t. a real variable x.  
However the three categories are not evenly spaced. You can see a MWE here which produces a pretty ugly plot.

```julia
julia> data = (y = rand(90), x = [fill(80,30); fill(320,30); fill(1280,30)]);

julia> boxplot(data.x, data.y)

```

In Plots, I used to convert the x variables to strings so that it would treat them as categories.

```julia
julia> boxplot(string.(data.x), data.y)

```

This does not work in Makie. I checked the roadmap for Makie and nothing concerning such a problem seems to be planned. So I’m guessing there’s already a solution that I don’t know about.  
Could anybody tell me how to get three evenly spaced boxes of the same width ?  
I know that I could convert the x variables to 1 2 and 3 but 1) that’s annoying to do and 2) it would not give the correct x labels on this axis.

---

<div class="post-metadata">

### Author: ![lazarusA](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lazarusa/32/6571_2.png) [@lazarusA](https://discourse.julialang.org/u/lazarusA)
#### Post date: [November 10, 2021, 4:17pm UTC](https://discourse.julialang.org/t/makie-categorical-x-variables/71263/2 "2021-11-10T16:17:36Z")

</div>

In makie, now you only need to take care of the ticks positions. See this example with a lot of options to customise your plot:

> <https://github.com/lazarusA/100daysOfMakie/blob/main/src/boxplot.jl>

 ![boxplot](https://global.discourse-cdn.com/julialang/original/3X/6/e/6e0560e1aa83b8a631f77b3fab4d1721b77124a5.png)

---

<div class="post-metadata">

### Author: ![HenriDeh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrideh/32/8316_2.png) [@HenriDeh](https://discourse.julialang.org/u/HenriDeh)
#### Post date: [November 10, 2021, 4:43pm UTC](https://discourse.julialang.org/t/makie-categorical-x-variables/71263/3 "2021-11-10T16:43:28Z")

</div>

Okay so it seems that the way to go is to do multiple `boxplot!` calls instead of a single one.

Thanks for the example (and the other ones, I hope you’ll find the time to finish the 100 days of plotting 🙂)
