'return list of gridline coordinates in data coordinates.
*which* : "major" or "minor"
*axis* : "both", "x" or "y"'

def get_gridlines(self, which=u'major', axis=u'both'):

    gridlines = []
    if (axis in [u'both', u'x']):
        locs = []
        (y1, y2) = self.axes.get_ylim()
        if (which in [u'both', u'major']):
            locs.extend(self.axes.xaxis.major.locator())
        if (which in [u'both', u'minor']):
            locs.extend(self.axes.xaxis.minor.locator())
        for x in locs:
            gridlines.append([[x, x], [y1, y2]])
    if (axis in [u'both', u'y']):
        (x1, x2) = self.axes.get_xlim()
        locs = []
        if self.axes.yaxis._gridOnMajor:
            locs.extend(self.axes.yaxis.major.locator())
        if self.axes.yaxis._gridOnMinor:
            locs.extend(self.axes.yaxis.minor.locator())
        for y in locs:
            gridlines.append([[x1, x2], [y, y]])
    return gridlines
