# Category-type axis in a scatter plot

**URL:** <https://discourse.julialang.org/t/category-type-axis-in-a-scatter-plot/68382>\
**Category:** Visualization\
**Tags:** question, plotting\
**Created:** [September 18, 2021, 7:20pm UTC](https://discourse.julialang.org/t/category-type-axis-in-a-scatter-plot/68382 "2021-09-18T19:20:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![emchateau](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/emchateau/32/28597_2.png) [@emchateau](https://discourse.julialang.org/u/emchateau)\
**Post date:** [September 18, 2021, 7:20pm UTC](https://discourse.julialang.org/t/category-type-axis-in-a-scatter-plot/68382/1 "2021-09-18T19:20:11Z")

</div>

Hi, I would like to give a category-type in x-axis of a scatter plot.  
I’ve seen the xaxis _discrete\_values_ attribute (cf. [Axis Attributes · Plots](https://docs.juliaplots.org/latest/generated/attributes_axis/)) But I couldn’t find a way to use it nor any working exemple.

Ex.

```julia
using DataFrame
using Plots
df = DataFrame(A = ["M", "F", "F", "M"], B = 1:4)
Plots.scatter(df[!, :B])
xaxis!(discrete_values = df[!, :A])

```

But the values are added to _x_ and _y_ after those created automatically.

Thanks in advance for your help.

---

<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:** [September 18, 2021, 8:11pm UTC](https://discourse.julialang.org/t/category-type-axis-in-a-scatter-plot/68382/2 "2021-09-18T20:11:16Z")

</div>

Did you try: `Plots.scatter(df.A, df.B)` ?

_NB: to have everything separated along the x-axis (which would be weird) you could do:_  
`Plots.scatter(df.B, xticks = (1:size(df,1), df.A))`

---

<div class="post-metadata">

**Author:** ![emchateau](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/emchateau/32/28597_2.png) [@emchateau](https://discourse.julialang.org/u/emchateau)\
**Post date:** [September 19, 2021, 10:40pm UTC](https://discourse.julialang.org/t/category-type-axis-in-a-scatter-plot/68382/3 "2021-09-19T22:40:25Z")

</div>

Thanks a lot, that was exactly what I was looking for.  
Is there a way to

> [@rafael.guerra](#):
>
> `Plots.scatter(df[!, :B], xticks=(1:size(df,1), df[!, :A]))`
