I want to try and specify a default theme for a recipe I’m writing, and in the style of the new Makie 0.24+ syntax, I have:
@recipe ConfidencePlot (x, y, ϵ) begin
... # some miscellaneous attributes
Theme(Axis(...))
end
But this throws an error even while precompiling:
ERROR: LoadError: Theme(Axis = (xlabel = "Effect Size", title = "Confidence Interval Plot", leftspinevisible = false, rightspinevisible = false, topspinevisible = false, xgridvisible = false, ygridvisible = false, yticksvisible = false)) is neither a valid attribute line like `x = default_value` nor a mixin line like `some_mixin...`
What is the accepted way to do this with the new syntax? This is very important for my recipe since I want to ensure that by default the plot the user get is themed in a particular way. Thank you so much!
Thank you for clarifying that! Is there any way at all to mimic this behavior with theming? I would really like if it was possible to somehow set the theme for the plot object as it was returned, but I understand if it’s not possible!
No it’s not possible with theming, your plotting function code runs after an implicit axis is created, so it’s too late for changing the theme. But this would be a rather roundabout way of doing it anway, to mutate the theme temporarily. Instead, it sounds like currently a recipe is not the right level of abstraction for what you want. So maybe just make a normal function and this can of course create an Axis. In the future, there might be ways to attach default axis parameters to recipes in case they create an axis implicitly.
Thank you for that! It’s not exactly what I am looking for – currently I do have a wrapper function around my recipe that uses with_theme() for this purpose, just to allow the user to have an abstraction that will be helpful. I am developing a package that I anticipate will be used by people not very experienced with Julia or Makie, and so I wanted to have a way for that wrapper function to return an object that can be used just like any other function in Makie – basically being able to plot two or three such plots on the same figure. Ordinarily I would just use the mutating version of the function and pass in the figure and axis, but if I do this I lose the Axis attributes. Conversely, if I do theme with the Axis attributes, then I can’t get the layout if I just call the wrapper function, since it returns an entire FigAxisPlot for each subplot. Is there an accepted way around this problem? Thank you so much for your help!