'Set the axis grid on or off; b is a boolean. Use *which* =
\'major\' | \'minor\' | \'both\' to set the grid for major or minor ticks.
If *b* is *None* and len(kwargs)==0, toggle the grid state.  If
*kwargs* are supplied, it is assumed you want the grid on and *b*
will be set to True.
*kwargs* are used to set the line properties of the grids, e.g.,
xax.grid(color=\'r\', linestyle=\'-\', linewidth=2)'

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

    if len(kwargs):
        b = True
    which = which.lower()
    if (which in [u'minor', u'both']):
        if (b is None):
            self._gridOnMinor = (not self._gridOnMinor)
        else:
            self._gridOnMinor = b
        for tick in self.minorTicks:
            if (tick is None):
                continue
            tick.gridOn = self._gridOnMinor
            if len(kwargs):
                tick.gridline.update(kwargs)
        self._minor_tick_kw[u'gridOn'] = self._gridOnMinor
    if (which in [u'major', u'both']):
        if (b is None):
            self._gridOnMajor = (not self._gridOnMajor)
        else:
            self._gridOnMajor = b
        for tick in self.majorTicks:
            if (tick is None):
                continue
            tick.gridOn = self._gridOnMajor
            if len(kwargs):
                tick.gridline.update(kwargs)
        self._major_tick_kw[u'gridOn'] = self._gridOnMajor
    self.stale = True
