@@ -1588,7 +1588,7 @@ def apply_aspect(self, position=None):
15881588 else :
15891589 self .set_xbound ((x0 , x1 ))
15901590
1591- def axis (self , * v , ** kwargs ):
1591+ def axis (self , * args , ** kwargs ):
15921592 """
15931593 Convenience method to get or set some axis properties.
15941594
@@ -1605,14 +1605,15 @@ def axis(self, *v, **kwargs):
16051605 The axis limits to be set. Either none or all of the limits must
16061606 be given.
16071607
1608- option : str
1609- Possible values:
1608+ option : bool or str
1609+ If a bool, turns axis lines and labels on or off. If a string,
1610+ possible values are:
16101611
16111612 ======== ==========================================================
16121613 Value Description
16131614 ======== ==========================================================
1614- 'on' Turn on axis lines and labels.
1615- 'off' Turn off axis lines and labels.
1615+ 'on' Turn on axis lines and labels. Same as ``True``.
1616+ 'off' Turn off axis lines and labels. Same as ``False``.
16161617 'equal' Set equal scaling (i.e., make circles circular) by
16171618 changing axis limits.
16181619 'scaled' Set equal scaling (i.e., make circles circular) by
@@ -1641,15 +1642,15 @@ def axis(self, *v, **kwargs):
16411642 matplotlib.axes.Axes.set_ylim
16421643 """
16431644
1644- if len (v ) == len (kwargs ) == 0 :
1645+ if len (args ) == len (kwargs ) == 0 :
16451646 xmin , xmax = self .get_xlim ()
16461647 ymin , ymax = self .get_ylim ()
16471648 return xmin , xmax , ymin , ymax
16481649
16491650 emit = kwargs .get ('emit' , True )
16501651
1651- if len (v ) == 1 and isinstance (v [0 ], str ):
1652- s = v [0 ].lower ()
1652+ if len (args ) == 1 and isinstance (args [0 ], str ):
1653+ s = args [0 ].lower ()
16531654 if s == 'on' :
16541655 self .set_axis_on ()
16551656 elif s == 'off' :
@@ -1694,7 +1695,7 @@ def axis(self, *v, **kwargs):
16941695 return xmin , xmax , ymin , ymax
16951696
16961697 try :
1697- v [0 ]
1698+ args [0 ]
16981699 except IndexError :
16991700 xmin = kwargs .get ('xmin' , None )
17001701 xmax = kwargs .get ('xmax' , None )
@@ -1711,9 +1712,18 @@ def axis(self, *v, **kwargs):
17111712 ymin , ymax = self .set_ylim (ymin , ymax , emit = emit , auto = auto )
17121713 return xmin , xmax , ymin , ymax
17131714
1714- v = v [0 ]
1715+ v = args [0 ]
1716+ if isinstance (v , bool ):
1717+ if v :
1718+ self .set_axis_on ()
1719+ else :
1720+ self .set_axis_off ()
1721+ xmin , xmax = self .get_xlim ()
1722+ ymin , ymax = self .get_ylim ()
1723+ return xmin , xmax , ymin , ymax
1724+
17151725 if len (v ) != 4 :
1716- raise ValueError ('v must contain [xmin xmax ymin ymax]' )
1726+ raise ValueError ('args must contain [xmin xmax ymin ymax]' )
17171727
17181728 self .set_xlim ([v [0 ], v [1 ]], emit = emit , auto = False )
17191729 self .set_ylim ([v [2 ], v [3 ]], emit = emit , auto = False )
0 commit comments