'Get the cursor data for a given event'

def get_cursor_data(self, event):

    (xmin, xmax, ymin, ymax) = self.get_extent()
    if (self.origin == u'upper'):
        (ymin, ymax) = (ymax, ymin)
    arr = self.get_array()
    data_extent = Bbox([[ymin, xmin], [ymax, xmax]])
    array_extent = Bbox([[0, 0], arr.shape[:2]])
    trans = BboxTransform(boxin=data_extent, boxout=array_extent)
    (y, x) = (event.ydata, event.xdata)
    (i, j) = trans.transform_point([y, x]).astype(int)
    if ((not (0 <= i < arr.shape[0])) or (not (0 <= j < arr.shape[1]))):
        return None
    else:
        return arr[(i, j)]
