Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 064ea12

Browse files
committed
documented new kwarg handling for grid
svn path=/trunk/matplotlib/; revision=2164
1 parent e3044a0 commit 064ea12

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

lib/matplotlib/axes.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1752,8 +1752,19 @@ def get_autoscale_on(self):
17521752
def grid(self, b=None, **kwargs):
17531753
"""
17541754
Set the axes grids on or off; b is a boolean
1755-
if b is None, toggle the grid state
1755+
1756+
if b is None and len(kwargs)==0, toggle the grid state. if
1757+
kwargs are supplied, it is assumed that you want a grid and b
1758+
is thus set to True
1759+
1760+
kawrgs are used to set the grid line properties, eg
1761+
1762+
ax.grid(color='r', linestyle='-', linewidth=2)
1763+
1764+
See getp(line) for more information on valid keywords for line
1765+
properties.
17561766
"""
1767+
if len(kwargs): b = True
17571768
self.xaxis.grid(b, **kwargs)
17581769
self.yaxis.grid(b, **kwargs)
17591770

lib/matplotlib/axis.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,8 +717,15 @@ def grid(self, b=None, which='major', **kwargs):
717717
Set the axis grid on or off; b is a boolean use which =
718718
'major' | 'minor' to set the grid for major or minor ticks
719719
720-
if b is None, toggle the grid state
720+
if b is None and len(kwargs)==0, toggle the grid state. If
721+
kwargs are supplied, it is assumed you want the grid on and b
722+
will be set to True
723+
724+
kwargs are used to set the line properties of the grids, eg,
725+
726+
xax.grid(color='r', linestyle='-', linewidth=2)
721727
"""
728+
if len(kwargs): b = True
722729
if which.lower().find('minor')>=0:
723730
if b is None: self._gridOnMinor = not self._gridOnMinor
724731
else: self._gridOnMinor = b

0 commit comments

Comments
 (0)