# Plots.jl xticks color modification

**URL:** <https://discourse.julialang.org/t/plots-jl-xticks-color-modification/74800>\
**Category:** Visualization\
**Tags:** plots\
**Created:** [January 18, 2022, 1:02pm UTC](https://discourse.julialang.org/t/plots-jl-xticks-color-modification/74800 "2022-01-18T13:02:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bienpierre](https://avatars.discourse-cdn.com/v4/letter/b/8c91f0/32.png) [@bienpierre](https://discourse.julialang.org/u/bienpierre)\
**Post date:** [January 18, 2022, 1:02pm UTC](https://discourse.julialang.org/t/plots-jl-xticks-color-modification/74800/1 "2022-01-18T13:02:03Z")

</div>

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.

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

```

![plot_julia](https://global.discourse-cdn.com/julialang/original/3X/d/e/de77f82b38b0b349664685d2d983552b742933fe.png)

regards

---

<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:** [January 18, 2022, 6:32pm UTC](https://discourse.julialang.org/t/plots-jl-xticks-color-modification/74800/2 "2022-01-18T18:32:25Z")

</div>

`using Plots`:  
 ![Plots_gr_with_multicolored_xticks](https://global.discourse-cdn.com/julialang/original/3X/2/b/2b394c5a8bb0fedd66b35b659fad839020746839.png)

> **CODE**
>
> ```julia
> 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)
> 
> ```

---

<div class="post-metadata">

**Author:** ![Slawomir\_Lasota](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/slawomir_lasota/32/49525_2.png) [@Slawomir\_Lasota](https://discourse.julialang.org/u/Slawomir_Lasota)\
**Post date:** [May 5, 2023, 9:41pm UTC](https://discourse.julialang.org/t/plots-jl-xticks-color-modification/74800/3 "2023-05-05T21:41:15Z")

</div>

Not exactly good. As xlabels contain a subscript it aligns to the subscripts, not the baseline.
