'Toggle the gridlines, and optionally set the properties of the lines.'

def grid(self, b=None, which=u'major', axis=u'both', **kwargs):

    super(Axes, self).grid(b, which=which, axis=axis, **kwargs)
    if (not self._axisline_on):
        return
    if (b is None):
        if (self.axes.xaxis._gridOnMinor or self.axes.xaxis._gridOnMajor or self.axes.yaxis._gridOnMinor or self.axes.yaxis._gridOnMajor):
            b = True
        else:
            b = False
    self.gridlines.set_which(which)
    self.gridlines.set_axis(axis)
    self.gridlines.set_visible(b)
    if len(kwargs):
        martist.setp(self.gridlines, **kwargs)
