This seems like a pretty simple problem, but I'm new to Python, and I'm struggling to solve it. I have a scatterplot / heatmap created from two numpy arrays (about 25,000 pieces of information). The y axis is taken directly from the array, and the x axis is generated from a simple subtraction operation on two arrays.
Now I need to take a snapshot of the data so that I can work with a choice that falls into certain parameters on the graph. For example, I need to extract all the points that fall into a parallelogram: 
I can cut a rectangle using simple inequalities (see indexing idx_c , idx_h and idx , below), but I really need a way to select points using more complex geometry. It seems that this slicing can be done by specifying the vertices of the polygon. This is approximately what I can find for the solution, but I cannot figure out how to implement it:
http://matplotlib.org/api/nxutils_api.html#matplotlib.nxutils.points_inside_poly
Ideally, I really need something similar to the indexing below, i.e. something like colorjh[idx] . In the end, I will have to build different values (for example, colorjh[idx] vs colorhk[idx] ), so the index must be passed to all arrays in the data set (many arrays). Perhaps this is obvious, but I would suggest that there are solutions that may not be as flexible. In other words, I will use this graph to select points of interest to me, and then I will need these indexes to work with other arrays from the same table.
Here is the code I'm working with:
import numpy as np from numpy import ndarray import matplotlib.pyplot as plt import matplotlib import atpy from pylab import * twomass = atpy.Table() twomass.read('/IRSA_downloads/2MASS_GCbox1.tbl') hmag = list([twomass['h_m']]) jmag = list([twomass['j_m']]) kmag = list([twomass['k_m']]) hmag = np.array(hmag) jmag = np.array(jmag) kmag = np.array(kmag) colorjh = np.array(jmag - hmag) colorhk = np.array(hmag - kmag) idx_c = (colorjh > -1.01) & (colorjh < 6)
As I said, I'm new to Python, so the fewer the explanations, the more likely I will be able to implement it. Thanks for any help you can provide.