@@ -94,15 +94,21 @@ function plot_graph(graph, edges = nothing; kwargs...)
9494 vec_map = vec (op. map)
9595 end
9696 # Interpolate map onto grid
97- # itp = interpolate((vec_x, vec_y), vec_map, Gridded(Linear()))
98- spl = Spline2D (vec_x, vec_y, vec_map, s = 0.1 )
9997 xmap = range (minimum (vec_x), stop= maximum (vec_x), length= 2 * length (vec_x))
10098 ymap = range (minimum (vec_y), stop= maximum (vec_y), length= 2 * length (vec_y))
101- Xmap, Ymap = xmap' .* ones (length (ymap)), ymap .* ones (length (xmap))'
102- Xmap, Ymap = Xmap[:], Ymap[:]
103- fmap = evaluate (spl, Xmap, Ymap)
104- # make fmap a matrix with same size as xmap and ymap
105- fmap = reshape (fmap, length (xmap), length (ymap))
99+ # itp = interpolate((vec_x, vec_y), vec_map, Gridded(Linear()))
100+ fmap = zeros (length (xmap), length (ymap))
101+ try
102+ spl = Spline2D (vec_x, vec_y, vec_map, s = 0.1 )
103+ Xmap, Ymap = xmap' .* ones (length (ymap)), ymap .* ones (length (xmap))'
104+ Xmap, Ymap = Xmap[:], Ymap[:]
105+ fmap_values = evaluate (spl, Xmap, Ymap)
106+ fmap = reshape (fmap_values, length (xmap), length (ymap))
107+ catch
108+ # println("Spline2D interpolation failed, falling back to linear interpolation")
109+ # If Spline2D interpolation fails, fall back to linear interpolation
110+ fmap = linear_interpolation_2d (vec_x, vec_y, vec_map, xmap, ymap)
111+ end
106112
107113 # Plot heatmap
108114 heatmap! (pl, xmap, ymap, fmap,
0 commit comments