Plots.jl xticks color modification

Hello,

Is it possible to change a specific xtick color with Plots.jl. For instance, tick 5 with red, tick 10 with yellow, etc. I tried with xtickfontcolor and all ticks are red.

using Plots
plot(1:20, randn(20); size(400,300), xtickfontcolor=:red)

plot_julia

regards

using Plots:
Plots_gr_with_multicolored_xticks

CODE
using Colors, Plots; gr(dpi=600)
theme(:dark)
colors0 = [:red, :orange, :yellow, :limegreen, :cyan, :blue, :violet, :brown, :black]

function multicolor_xticks!(colors0)
    p = Plots.current()
    xticks, xlabels = Plots.xticks(p)[1]
    yl = Plots.ylims(p)
    y0 = @. zero(xticks) + yl[1] - 0.06*(yl[2] - yl[1])
    n = length(xticks)
    colors = colors0[1:n]
    xticks!(xticks, fill(" ",n))
    [annotate!(xi,yi,text(li,9,ci,:bottom)) for (xi,yi,li,ci) in zip(xticks, y0, xlabels, colors)]
    return Plots.current()
end

# useage
plot(1:20, randn(20), xlabel="x", ylabel="y")
multicolor_xticks!(colors0)
1 Like