I’m trying a write a recipe in Makie, but cannot use the extracted x and y values from the recipe. I’m following the example in the documentation, as well as the examples in basic_recipes.jl (particularly pie.jl). The error message seems to indicate that MyPlot
does take any arguments, but I thought the @recipe
macro expands into a type definition that includes the plot and argument types.
I want to extract the arguments so that I can operate on them by changing a length and angle (r, θ)
to (x, y)
coordinates to make a polar plot. I provide just a basic example below closely following the docs.
Recipe:
@recipe(MyPlot, x, y) do scene
Theme(
plot_color = :red
)
end
Try 1:
function plot!(myplot::MyPlot)
x = myplot[1]
y = myplot[2]
scatter!(myplot, x, y, color = myplot.plot_color)
myplot
end
Try 2:
function plot!(myplot::MyPlot)
x = myplot[:x]
y = myplot[:y]
scatter!(myplot, x, y, color = myplot.plot_color)
myplot
end
Plot:
f = Figure
ax = Axis(f[1, 1])
myplot(ax, rand(10), rand(10))
Error message:
ERROR: PlotMethodError: no myplot method for arguments (::Axis, ::Vector{Float64}, ::Vector{Float64}). To support these arguments, define
plot!(::Combined{myplot, S} where S<:Tuple{Axis, Vector{Float64}, Vector{Float64}})