# Tick size in Plots.jl

**URL:** <https://discourse.julialang.org/t/tick-size-in-plots-jl/74793>\
**Category:** General Usage\
**Tags:** question, plots, gr\
**Created:** [January 18, 2022, 11:21am UTC](https://discourse.julialang.org/t/tick-size-in-plots-jl/74793 "2022-01-18T11:21:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gabrielmlando](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gabrielmlando/32/20628_2.png) [@Gabrielmlando](https://discourse.julialang.org/u/Gabrielmlando)\
**Post date:** [January 18, 2022, 11:21am UTC](https://discourse.julialang.org/t/tick-size-in-plots-jl/74793/1 "2022-01-18T11:21:55Z")

</div>

I am having a very hard time trying to increase tick size in Plots.jl using gr(). Apparently there is no documentation on this either. Is there a way to do it?

---

<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, 12:30pm UTC](https://discourse.julialang.org/t/tick-size-in-plots-jl/74793/2 "2022-01-18T12:30:11Z")

</div>

The ticks’ thickness can be increased together with the axes - [see manual section here](https://docs.juliaplots.org/stable/attributes/#notable-arguments). The axes labels fonts will increase too. To avoid that do:

```julia
using Plots; gr()
a = 2/3
Plots.scalefontsizes(a)
plot(sin, thickness_scaling = 1/a)
# Plots.reset_defaults()

```

---

<div class="post-metadata">

**Author:** ![Gabrielmlando](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gabrielmlando/32/20628_2.png) [@Gabrielmlando](https://discourse.julialang.org/u/Gabrielmlando)\
**Post date:** [January 18, 2022, 12:38pm UTC](https://discourse.julialang.org/t/tick-size-in-plots-jl/74793/3 "2022-01-18T12:38:12Z")

</div>

I have found the solution regarding thickness, thanks! However, what I really want to increase is length, while keeping thickness fixed.

---

<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, 1:48pm UTC](https://discourse.julialang.org/t/tick-size-in-plots-jl/74793/4 "2022-01-18T13:48:37Z")

</div>

Check the simple `ticks_length!()` function herein to increase the ticks length:

```julia
function ticks_length!(;tl=0.02)
    p = Plots.current()
    xticks, yticks = Plots.xticks(p)[1][1], Plots.yticks(p)[1][1]
    xl, yl = Plots.xlims(p), Plots.ylims(p)
    x1, y1 = zero(yticks) .+ xl[1], zero(xticks) .+ yl[1]
    sz = p.attr[:size]
    r = sz[1]/sz[2]
    dx, dy = tl*(xl[2] - xl[1]), tl*r*(yl[2] - yl[1])
    plot!([xticks xticks]', [y1 y1 .+ dy]', c=:black, labels=false)
    plot!([x1 x1 .+ dx]', [yticks yticks]', c=:black, labels=false, xlims=xl, ylims=yl)
    return Plots.current()
end

# usage:
x = 0:0.01:2π; y = 0.1sin.(x)
plot(x,y)
ticks_length!()

plot(x,y)
ticks_length!(tl=0.015)

```

---

<div class="post-metadata">

**Author:** ![Gabrielmlando](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gabrielmlando/32/20628_2.png) [@Gabrielmlando](https://discourse.julialang.org/u/Gabrielmlando)\
**Post date:** [January 19, 2022, 8:43am UTC](https://discourse.julialang.org/t/tick-size-in-plots-jl/74793/5 "2022-01-19T08:43:25Z")

</div>

This is very handy! It’s unfortunate that the option is not implemented, but your fix certainly does the job for me. Thanks!

Edit: It doesn’t look like it works with 3D plots, though.

---

<div class="post-metadata">

**Author:** ![james](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@james](https://discourse.julialang.org/u/james)\
**Post date:** [April 17, 2024, 1:02pm UTC](https://discourse.julialang.org/t/tick-size-in-plots-jl/74793/6 "2024-04-17T13:02:38Z")

</div>

Is there any way to do the same for minor ticks? Replacing

```julia
Plots.xticks(p)

```

by

```julia
Plots.xminorticks(p)

```

does not work and the documentation is very sparse on that.

---

<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:** [April 17, 2024, 5:59pm UTC](https://discourse.julialang.org/t/tick-size-in-plots-jl/74793/7 "2024-04-17T17:59:48Z")

</div>

Just poking around in the source code [here](https://github.com/JuliaPlots/Plots.jl/blob/09d7bdac381033935adeccfc651c369fb574d714/test/test_axes.jl#L242), to get the position of the minor xticks we can do:

```julia
using Plots; gr()
p = plot(size=(600,600), xlim=(1.1,5.3), ylim=(-0.1,3.0), xminorticks=2, yminorticks=2)
sp = first(p)
ticks = xticks(sp)
minor_ticks = Plots.get_minor_ticks(sp, sp[:xaxis], ticks)

```
