surface plot with masked elements?

I need to make a surface plot where some corner elements of my 2D data are
invalid, and I'd like to omit them from the plot.

I've seen a couple of stackoverflow questions on the subject, but none of
the answers seemed satisfactory (or I understood).

It's been some years now, what is the current "best" approach to this
question?

Neal Becker wrote:

I need to make a surface plot where some corner elements of my 2D data are
invalid, and I'd like to omit them from the plot.

I've seen a couple of stackoverflow questions on the subject, but none of
the answers seemed satisfactory (or I understood).

It's been some years now, what is the current "best" approach to this
question?

I'm trying to follow the approach used here
https://stackoverflow.com/questions/11020160/plotting-a-masked-surface-plot-using-python-numpy-and-matplotlib

My code looks like:

lev = np.linspace(np.min(abs(H)),np.max(abs(H)),10)
import matplotlib.colors as colors
norml = colors.BoundaryNorm(lev, 256)
ax.plot_surface(grid_x, grid_y, H_2d, cmap=cm.Blues, norm=norml)

The numbers '256' and '10' in the above seem to have no particular effect.
I'm thinking plot_surface is re-quantizing the colormap?