I am very sorry for the cumbersome title, but I don't find a way to express it clearly. The task that I should accomplish here is, given three numpy arrays containing coordinate matrices (X, Y) and the evaluation of a real function in this grid (Z); to obtain contour plots of the data. However, some of the coordinates give place to unacceptable Z values, and shouldn't be considered in the plots. What I have done so far:
cmap = plt.cm.get_cmap("winter")
cmap.set_under("magenta")
cmap.set_over("yellow")
with PdfPages('myplot.pdf') as pdf:
fig = plt.figure()
CS = plt.contourf(X, Y, Z, cmap=cmap)
cbar = plt.colorbar(CS)
cbar.ax.set_ylabel('Z')
plt.xlabel('X (\AA)')
plt.ylabel('Y (\AA)')
plt.tight_layout()
pdf.savefig(fig)
However, I don't find a proper way to restrict the values that should be taken into account in the plots (something like Zmin < Z < Zmax). I thought on the methods set_under and set_over of cmap, but it doesn't seem to be the way. Any suggestion abut this problem? Thank you very much in advance.