Change xticks in Makie.jl recipe

How can I set the xticks in this recipe?

import Dates
import TimeSeries
using CairoMakie
using PlotUtils: optimize_datetime_ticks

dates = Dates.DateTime(2018, 1, 1):Dates.Day(1):Dates.DateTime(2018, 12, 31)
data = TimeSeries.TimeArray(dates, cumsum(randn(length(dates))))

@recipe(MyTimeSeries, ta) do scene
    Theme()
end

function Makie.plot!(plot::MyTimeSeries)
    data = to_value(plot[:ta])
   
    for i in 1:size(data,2)
        lines!(plot, Dates.value.(TimeSeries.timestamp(data)), TimeSeries.values(data)[:,i], label=string(TimeSeries.colnames(data)[i]))
    end

    dateticks = optimize_datetime_ticks(Dates.value.(extrema(data |> TimeSeries.timestamp))...)
    # TODO:
    plot
end

begin
    f = Figure()
    ax = Axis(f[1, 1])
    mytimeseries!(ax, data)
    f
end

You can’t, yet. Makie’s recipes are older than the Axis types, we have to change things in the backend before this is possible. Currently, you can use simple functions if you have axes parameters you need to edit.

are there any news or issues about this that I can track? :smiley: Because I’d need the same feature to make the axis show categorical data when updating the plot.

2 Likes