I have data that can be plotted as scatter (GLMakie). I would like to convert the scatter into a surface. I tried to interpolate the data as following but it does not work (probably because of the way I use interpolate). Could you help ? Thanks

fig = Figure(size=(1200, 400))
axs = Axis3(fig[1,1])
hm = scatter!(axs, X_plan, Y_plan, palier_2)
fig
function meshgrid(x, y)
X = repeat(x', length(y), 1)
Y = repeat(y, length(x), 1)
return X, Y
end
# Define the grid to interpolate
x_range = range(minimum(X_plan), stop=maximum(X_plan), length=50)
y_range = range(minimum(Y_plan), stop=maximum(Y_plan), length=50)
# Create a grid for evaluation
X_grid, Y_grid = meshgrid(x_range, y_range)
# Perform the interpolation
itp = interpolate(X_plan, Y_plan, palier_2, Gridded(Linear()))
Z_grid = [itp(x, y) for (x, y) in zip(X_grid, Y_grid)]
# Plot the interpolated surface
fig = Figure(size=(1200, 400))
axs = Axis3(fig[1, 1])
surface!(axs, X_grid, Y_grid, Z_grid, color = :viridis)
fig

Can you please provide the full example with the definitions of arrays X_plan, Y_plan, and palier_2. I guess, that if palier_2 is an ordinary three dimensional array, then you do not need to do any interpolation.

I mean your code in your first post should actually define example data that someone can use, and should also bring in the necessary packages via using. It will make it more likely that someone will give their time to help you.