plot FOO using 1:2:3 mask with {pm3d|image}
Once a mask has been defined, you can use it as a filter to select a subset of points from an image or pm3d plot. See masking.