Is there a way in Makie.jl to have log-scale for the axes in a plot?
I can’t seem to find any mention about it in the official documentation
1 Like
There has been some discussion in https://github.com/JuliaPlots/Makie.jl/issues/557
but it is a feature I also sorely miss.
2 Likes
This is now implemented! See the documentation for alternative axis scales, presumably coming from the discussion linked to by @vchuravy.
The above doc links doesn’t work anymore. Just for future reference here is the correct link:
5 Likes
Now this link: Axis
1 Like
To save other people some searching, you can now set xscale
to some scaling function like log10
. From the docs:
using CairoMakie
f = Figure()
for (i, scale) in enumerate([identity, log10, log2, log, sqrt, Makie.logit])
row, col = fldmod1(i, 2)
Axis(f[row, col], xscale = scale, title = string(scale),
xminorticksvisible = true, xminorgridvisible = true,
xminorticks = IntervalsBetween(5))
lines!(range(0.01, 0.99, length = 200), 1:200)
end
f
1 Like
yticklabels
can be used to make the axes more readable:
let
fig = Figure()
rate = 1.1
xs = 1:60
ys = [100 * rate^x for x in xs]
yticks = [10 * rate^x for x in xs]
yticks = [ceil(Int, 10 * 2^i) for i in 1:100]
yticklabels = ["\$$y" for y in yticks]
ax = Axis(fig[1, 1]; yscale=log10, yticks=(yticks, yticklabels))
scatterlines!(ax, xs, ys)
fig
end
1 Like