I have two different arrays of structs that I'd like to build a recipe for: typeof(nodes) == Array{Node{TF}, 1} and typeof(elements) == Array{Element{TF}, 1} (where TF is commonly a Float64). I'd love to be able to do something like plot(nodes, elements) and get back a plot object without adding Plots to my package, I'd prefer the lighter weight RecipesBase.
I've read the documentation, the overview, and this discussion on using RecipesBase.
I was able to get a user recipe working by creating a placeholder struct NodeMesh that simply holds the arrays nodes and elements. The function signature of the recipe looks like: @recipe function plot_mesh(nodemesh::NodeMesh). (And then I promptly unpack the struct inside of the recipe.)
This approach seems ...wrong? I mean it works, but I also could just define a function that returns a dictionary that I pass to Plots. It seems like the series recipe is the correct solution, but I can't get it to work. I've tried a couple of different variations of the function signature (all of which didn't work):
@recipe function f(::Type{Val{:gxmesh}}, nodes, elements)
@recipe function plot_mesh(nodes::Vector{Node}, elements::Vector{MeshElement})
@recipe function plot_mesh(nodes::Array{Node}, elements::Array{MeshElement})
What's the correct approach here? What am I missing?
I found a potential answer in the issues of
RecipeBase.Here's how I changed the function signature that worked:
That function returns the x and y of the things I want to plot.