-
-
Notifications
You must be signed in to change notification settings - Fork 317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example recipe in docs doesn't work #771
Comments
I can't get the basic example on the docs to work either. For Makie v0.13.9, the following simplified example using GLMakie
@recipe(MyPlot, x) do scene
Theme(
plot_color=:red
)
end
function Makie.plot!(myplot::MyPlot{<:Tuple{Vector{Float64}}})
lines!(myplot, rand(10), color = myplot[:plot_color])
plot!(myplot, myplot[:x])
myplot
end gives the error julia> myplot(1:3)
ERROR: MethodError: no method matching plotsym(::Type{Combined{Any, Tuple{UnitRange{Int64}}}})
Closest candidates are:
plotsym(::Type{Any}) at /Users/jessechan/.julia/packages/Makie/FXx4Q/src/recipes.jl:4
plotsym(::Type{var"#s298"} where var"#s298"<:(Arrows{ArgType} where ArgType)) at /Users/jessechan/.julia/packages/Makie/FXx4Q/src/recipes.jl:135
plotsym(::Type{var"#s298"} where var"#s298"<:(Arc{ArgType} where ArgType)) at /Users/jessechan/.julia/packages/Makie/FXx4Q/src/recipes.jl:135 I'm happy to do a doc PR if I can figure out what's going wrong. |
Yeah I also just noticed that something is broken here... I'll overwork the recipe documentation + add tests over the coming days.. |
@SimonDanisch thanks! And no worries - I reverse-engineered it using @juliohm's example. using GLMakie
@Makie.recipe(MyPlot, x,y,z) do scene
Theme(;
color = :red,
)
end
function Makie.plot!(myplot::MyPlot{<:Tuple{<:AbstractVector,<:AbstractVector,<:AbstractVector}})
lines!(myplot, randn(10), color=myplot[:color])
plot!(myplot, myplot[:x][], myplot[:y][])
myplot
end I can still open a docs PR so there's a working example until the MakieCore refactor finishes? |
Also, it was a bit surprising that |
The trick is that using Makie
import Makie: plot, plot!
using GLMakie
## second examples
@recipe(MyPlot, x, y) do scene
Theme(
plot_color=:red
)
end
function plot!(myplot::MyPlot)
# normal plotting code, building on any previously defined recipes
# or atomic plotting operations, and adding to the combined `myplot`:
lines!(myplot, rand(10), color=myplot.plot_color)
plot!(myplot, myplot.x, myplot.y)
myplot
end
myplot(1:10, 1:10) |
The docs at http://makie.juliaplots.org/stable/recipes.html#Full-recipes-with-the-@recipe-macro suggest that this should work (although it's not presented as a complete example in a single block, but in two parts):
There are two trivial problems:
plot_color=>:red
should beplot_color=:red
, andplot!
should be fully qualified to extend it (or there should beimport AbstractPlotting: plot!
).After fixing these, it still fails:
The text was updated successfully, but these errors were encountered: