Matplotlib's 'plot_surface' function can't handle masked arrays properly (either masking with NaNs or using numpy masked arrays).
To plot a masked surface with 'plot_surface', a small trick must be applied. Sadly, the edges are not smooth even with this method.
Another function 'plot_trisurf' can be the solution to this problem. In this tutorial, I cover this approach after demonstrating what's wrong with 'plot_surface'.
Music by 4barrelcarb at https://freesound.org/people/4barrelc...
Sound effects obtained from https://www.zapsplat