Category-type axis in a scatter plot

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) But I couldn’t find a way to use it nor any working exemple.

Ex.

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.

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))

1 Like

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