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?
The ticks’ thickness can be increased together with the axes - see manual section here. The axes labels fonts will increase too. To avoid that do:
using Plots; gr()
a = 2/3
Plots.scalefontsizes(a)
plot(sin, thickness_scaling = 1/a)
# Plots.reset_defaults()
I have found the solution regarding thickness, thanks! However, what I really want to increase is length, while keeping thickness fixed.
Check the simple ticks_length!()
function herein to increase the ticks length:
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)
2 Likes
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.