How to plot more ticks in AlgebraOfGraphics or Makie?

I ran into this same issue too (`LinearTicks` seems to alter the formatting for timeseries data · Issue #232 · MakieOrg/AlgebraOfGraphics.jl · GitHub).

I think there is work being done upstream (https://github.com/JuliaPlots/Makie.jl/pull/1347) so that we can handle time axes directly with Makie, but in the meantime @piever added this convenience function in AoG that I think is really handy:

julia> using AlgebraOfGraphics, GLMakie, Dates

julia> t = DateTime(2021, 1, 1):Month(1):DateTime(2022, 1, 1);

julia> y = randn(length(t));

julia> df = (; t, y);

julia> ticks = AlgebraOfGraphics.datetimeticks(monthname, df.t[begin:2:end]);

julia> plt = data(df) * mapping(:t, :y) * visual(Lines);

julia> draw(plt; axis=(; xticks=ticks))

You can pass any formatting function you want, although you will still need to play with the array of time points that is actually passed to it

3 Likes