Skip to content

Commit 0b46bb9

Browse files
committed
fixed grid toggle
svn path=/trunk/matplotlib/; revision=717
1 parent 4b5aa6b commit 0b46bb9

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

lib/matplotlib/axes.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,8 +1208,11 @@ def get_yticks(self):
12081208
'Return the y ticks as a list of locations'
12091209
return self.yaxis.get_ticklocs()
12101210

1211-
def grid(self, b):
1212-
'Set the axes grids on or off; b is a boolean'
1211+
def grid(self, b=None):
1212+
"""
1213+
Set the axes grids on or off; b is a boolean
1214+
if b is None, toggle the grid state
1215+
"""
12131216
self.xaxis.grid(b)
12141217
self.yaxis.grid(b)
12151218

lib/matplotlib/axis.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,10 +615,12 @@ def get_minor_ticks(self):
615615

616616
return ticks
617617

618-
def grid(self, b, which='major'):
618+
def grid(self, b=None, which='major'):
619619
"""
620620
Set the axis grid on or off; b is a boolean use which =
621621
'major' | 'minor' to set the grid for major or minor ticks
622+
623+
if b is None, toggle the grid state
622624
"""
623625
if which.lower().find('minor')>=0:
624626
if b is None: self._gridOnMinor = not self._gridOnMinor

0 commit comments

Comments
 (0)