fig = plt.figure(figsize=(15, 8))
ax = plt.axes(projection='3d')
bar5 = ax.scatter3D(xs=result[:, 0], ys=result[:, 1], zs=out2.reshape(-1), c= out2.reshape(-1), cmap=cm.coolwarm);
levels = np.linspace(0, 1, 15)
contour = ax.contour3D(X, Y, Z, levels, cmap=cm.coolwarm, linestyles="solid") # The Z must be a 2d shape
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z');
ax.set_title('3D visualization with contour')
plt.colorbar(contour)