How to define default plotting attributes for all my recipes using only `RecipesBase.jl`?

I have several @recipes, which share the same plotattributes, such as framestyle, grid, legend_foreground_color, etc. If Plots.jl is imported, I could just use default, right? But is it possible that I only use RecipesBase.jl without Plots.jl in my project?

MWE:

using RecipesBase: @recipe

@recipe function f(x, y)
    framestyle --> :box
    legend_foreground_color --> nothing
    grid --> nothing
    x, y
end
@recipe function f(x)
    framestyle --> :box
    legend_foreground_color --> nothing
    grid --> nothing
    x
end
1 Like

I’d like to know too. It seems like most packages just copy and paste attributes for each of their plot functions (example, not to pick on Measurements.jl)

You can’t really write a macro to inject your own defaults either, because macros expand from outside-in. I guess you could write one that injected a bunch of things that look like

RecipesBase.is_explicit(plotattributes, :labels) || (plotattributes[:labels] = nameof(ts))

but then you’d be relying on the implementation details of the @recipe macro that are likely to change in the future.