I am creating a custom surface plot piece-by-piece inside of a for loop. Here’s a very simplified example:
mutable struct MyPlotType{T}
x::T
end
@recipe function f(::Type{MyPlotType{T}}, my_plot_type::MyPlotType{T}) where {T}
return my_plot_type.x, my_plot_type.x
end
# This is slow
x = [LinRange(i-1, i, 100) for i in 1:10]
@time begin
Plots.plot()
for i in 1:10
plot!(MyPlotType(x[i]))
end
end
It’s much faster to concatenate the plot inputs Plots.plot(MyPlotType(vcat(x...)))
than to call plot!
inside the loop. However, I’d like to avoid concatenating the plot inputs for my actual example since it’s more complex.
Is there a suggested way to speed this up? Should I be creating a custom plot recipe for Vector{MyPlotType}
?