I would like to request some help updating some of my plotting recipes to the new v0.24 style. I know the issue lies with the new attribute system and the computational graph (and no longer being able to manipulate it like a Dict
), but I can’t figure out how to make them work.
For reference, I’m doing something in-between a simple argument conversion recipe and a full-blown recipe. I’m not defining a new plotting function, but I am needing something more complex than argument conversion, so that I can pass through keyword arguments.
Minimum working example:
struct Foo
x::Vector{Float64}
y::Vector{Float64}
color::Symbol
end
Makie.convert_arguments(::PointBased, foo::Foo) = (foo.x, foo.y)
# I can plot x vs y like this, but it does not set the color automatically
foo = Foo(1:10, 1:10, :red)
scatter(foo)
# therefore, I overload the plot! function, like a full @recipe would
function Makie.plot!(plot::Plot(Foo))
map!(plot.attributes, [:arg1], [:scatter, :color]) do foo
return (foo, foo.color)
end
scatter!(plot, plot.attributes, plot.scatter, color=plot.color)
end
# I can plot x vs y with correct color like this
plot(foo)
# however, I can't figure out how to make this work
plot(foo, markersize=10)
In the past, keyword arguments would get passed through, but it seems now that they aren’t. I could also manipulate the dictionary of attributes in my plot!
function (could check to see if certain arguments were set, overwrite them, etc…); I don’t need that currently, but it could also be nice to know how to do that.
I think the issue stems from Recipes | Makie noting that the child plot will pick out the relevant attributes, but I’m perhaps not setting them for my overloaded Plot(foo)
type. I tried the following, but it did not work:
Makie.documented_attributes(::Type{Plot(Foo)}) = Makie.documented_attributes(Scatter)
so tl;dr, in Makie v0.24, what is the correct way to inherit default attributes and pass them through to the child for an overloaded plot!
function? Thanks!