diff ext/DiffinitiveMakieExt.jl @ 1796:4d55ac2892a2 feature/grids/curvilinear

Improve plotting of grids so that it can handle embedded grids
author Jonatan Werpers <jonatan@werpers.com>
date Tue, 01 Oct 2024 11:24:40 +0200
parents 471a948cd2b2
children
line wrap: on
line diff
--- a/ext/DiffinitiveMakieExt.jl	Tue Oct 01 11:04:22 2024 +0200
+++ b/ext/DiffinitiveMakieExt.jl	Tue Oct 01 11:24:40 2024 +0200
@@ -33,12 +33,12 @@
 
 ## Grids
 
-Makie.convert_arguments(::Type{<:Scatter}, g::Grid) = (reshape(map(Point,g),:),) # (map(Point,collect(g)[:]),)
-function Makie.convert_arguments(::Type{<:Lines}, g::Grid{<:Any,2})
+Makie.convert_arguments(::Type{<:Scatter}, g::Grid) = (reshape(map(Point,g),:),)
+function Makie.convert_arguments(::Type{<:Lines}, g::Grid{<:AbstractVector})
     M = collect(g)
 
     function cat_with_NaN(a,b)
-        vcat(a,[@SVector[NaN,NaN]],b)
+        vcat(a,[@SVector fill(NaN, coordinate_size(g))],b)
     end
 
     xlines = reduce(cat_with_NaN, eachrow(M))
@@ -47,7 +47,7 @@
     return (cat_with_NaN(xlines,ylines),)
 end
 
-Makie.plot!(plot::Plot(Grid{<:Any,2})) = lines!(plot, plot.attributes, plot[1])
+Makie.plot!(plot::Plot(Grid)) = lines!(plot, plot.attributes, plot[1])
 
 
 ## Grid functions