Makie recipe specialisation for specific types?

There are a couple approaches I would recommend.

For the 1D case, it looks like the input data is the same whether you’re using scatter, bars or lines. In that case, I would recommend defining:

function AbstractPlotting.convert_arguments(::AbstractPlotting.PointBased, spec::KmerFrequency{1})
    # lower to a Vector{Point2f0} or a Tuple{Vector{Float32}, Vector{Float32}}
end

which should then work with all point-based plot types (lines, scatter, barplot, poly, etc).
You can also overload specific recipes (eg barplot) by:

function AbstractPlotting.convert_arguments(::Type{<: BarPlot}, spec::KmerFrequency{1})
    # lower to something barplot understands
end

which will take precedence over the generic method for barplots.

If you want 2D handling…well. There are a couple ways to go about it.

One way is to say “make your contours yourself” and just define:

function AbstractPlotting.convert_arguments(::AbstractPlotting.SurfaceLike, spec::KmerFrequency{2})
    # lower to something which e.g. heatmap or contour understand
end

which will work with contour, heatmap, surface, etc.

The other is to create your own recipe. This is really just a matter of personal preference.

For the 1D barplot, I would highly recommend rolling your own recipe. That could be as simple as:

@recipe(SpectraCN) do scene
    default_theme(scene, BarPlot)
end

function AbstractPlotting.plot!(p::SpectraCN)
    # lower to potentially multiple barplots/plots here 
end

I would personally advise against creating a single monorecipe which can generate multiple plot types, just because it can get kinda confusing for the user. This way, you can allow the user to use standard Makie plot types, while also offering them their own convenience.

2 Likes