I have a few numpy array containing data that I would visualize in a 2D grid. Some data is not physical, and I would like to mask this data. However, I could not figure out how to set the mask attribute correctly tricontour. I tried:
import matplotlib.pyplot as mp
import numpy as np
with open('some_data.dat', 'r') as infile:
x, y, z = np.loadtxt(infile, usecols=(0, 1, 2), unpack=True)
isbad = np.less(z, 1.4) | np.greater(z, 2.1)
mp.tricontourf(x, y, z, mask = isbad)
But the result is simply not masked. I tried the masking part of the contour plot in matplotlib , i.e.
z2 = np.ma.array(z, mask= isbad)
mp.tricontourf(x, y, z2)
which didn't work either. I want to use tricontourfinstrad contourfbecause I do not want to group my data.
z[isbad] = np.nan
results in a Segmentation error when tricontourf is called
Here is the figure, the red colors are the ones that I would like to mark as non-physical. 