Light-dependency recipes, complex recipes with layouts and axis access, and Layoutable recipes #1325
Replies: 3 comments
-
|
Beta Was this translation helpful? Give feedback.
-
Here's another idea. The problem with the previous approach was that Scene is not aware of Blocks, so there's duplication in data storage between Scene (stores the block's plots) and Figure (stores the Block) and it's not easy to remove a Block (need to keep track of what was put into the parent scene). Also, it's too much overhead to have each Block have a Scene. Here's a revised list of features I would like to have: AbstractBlock
|
Beta Was this translation helpful? Give feedback.
-
I wonder if this discussion went anywhere after what's visible in the current thread... This would be a very useful piece of functionality, and the design proposed by @jkrumbiegel in the first post does seem very reasonable:
I played with a helper macro that is used this way: Makie.convert_arguments(::Type{Scatter}, x::MyType) = ... regular convert_arguments stuff ...
MakieExtra.@define_plotfunc scatter MyType
MakieExtra.default_axis_attributes(::Type{Scatter}, x::MyType) = (; xlabel=..., ylabel=..., aspect=...)
scatter(MyType()) # creates axis with the attributes from default_axis_attributes()
scatter!(ax, MyType()) # just plots the data without any axis modifications and find this quite useful already. Would be best if there was such a What do you think of this design? |
Beta Was this translation helpful? Give feedback.
-
MakieCore already only depends on
Observables
. All other dependencies seem not strictly necessary to support plot recipes. The story could be a bit different with layouts, asGridLayoutBase
carries a couple dependencies of its own, for exampleGeometryBasics
.Currently, each plotting function defined with
@recipe
has its own function type, which is also embedded in theCombined
parametric type, which makes up the actual plot type. This means that to use any of the plots defined in Makie.jl (not MakieCore) one would currently have tousing Makie
to get access to these plot types.One option would be to make
plot(:Violin, args...
orplot(Val(:Violin), args...
equivalent toviolin(args...
so that packages who want to offer Makie recipes can use the necessary plotting functions through these Symbols.Recipe axis access
A missing feature is axis access for recipes, or at least the ability to set default axis properties from a recipe. Because the real
Axis
,Axis3
etc types are quite heavy, it's not feasible to put them into the recipe system. But it should at least be possible to allow recipes to set certain axis attributes. For that, again the mere reference to, e.g.,:Axis
bySymbol
could be enough.At what point in the pipeline should the axis keywords be generated? Currently, the axis is always created before a plot object is instantiated, which is then plotted directly into the new axis. But recipes will probably want to put the code for the plot and the code for computing axis keywords close together, as the information going into the plot will also overlap with the information styling the axis. It's not entirely clear where that logic should go, as it seems impractical to return both a plot object and axis attributes (and also figure attributes, if we're at it) from a
plot!
method. Maybe an empty axis keyword dictionary could be passed to theplot!
method, which it could then populate if it wants to. That would leave the return type as just the plot object.Maybe a function like
get_axis_attributes(plottype, axistype, args...; kwargs...)
would be cleaner, which would be called before the actualplot!
method, and before the axis has been created. But this would again have the problem of being separate from the direct plotting logic, which could lead to code duplication when extracting information from input arguments etc. This could also handle the different keywords for different axis types better, in case a plot method wants to set different labels for Axis and Axis3, for example....
more on the other topics later
Beta Was this translation helpful? Give feedback.
All reactions