How to set xtick names in Gadfly plots?

Hi all,

I would like to see letters A,B,C,D in the xticks positions of the plot example below. Please, how cold I set this?

using Gadfly, Random
set_default_plot_size(14cm, 8cm)
Random.seed!(1234)
plot(x=rand(10), y=rand(10), Stat.xticks(ticks=[0.0, 0.1, 0.9, 1.0]), Geom.point)

Thank you for your time and help

1 Like

You can use the labels option in Scale.x_continuous to overwrite the labels :

xticks = [0.0, 0.1, 0.9, 1.0]
labels = Dict(zip(xticks, ["A","B","C","D"]))

plot(
    x = rand(10), y = rand(10), 
    Stat.xticks(ticks = xticks),
    Scale.x_continuous(labels = x -> labels[x]),
    Geom.point
)
3 Likes