@@ -1589,7 +1589,7 @@ def apply_aspect(self, position=None):
15891589 else :
15901590 self .set_xbound ((x0 , x1 ))
15911591
1592- def axis (self , * v , ** kwargs ):
1592+ def axis (self , * args , ** kwargs ):
15931593 """
15941594 Convenience method to get or set some axis properties.
15951595
@@ -1606,14 +1606,15 @@ def axis(self, *v, **kwargs):
16061606 The axis limits to be set. Either none or all of the limits must
16071607 be given.
16081608
1609- option : str
1610- Possible values:
1609+ option : bool or str
1610+ If a bool, turns axis lines and labels on or off. If a string,
1611+ possible values are:
16111612
16121613 ======== ==========================================================
16131614 Value Description
16141615 ======== ==========================================================
1615- 'on' Turn on axis lines and labels.
1616- 'off' Turn off axis lines and labels.
1616+ 'on' Turn on axis lines and labels. Same as ``True``.
1617+ 'off' Turn off axis lines and labels. Same as ``False``.
16171618 'equal' Set equal scaling (i.e., make circles circular) by
16181619 changing axis limits.
16191620 'scaled' Set equal scaling (i.e., make circles circular) by
@@ -1642,15 +1643,15 @@ def axis(self, *v, **kwargs):
16421643 matplotlib.axes.Axes.set_ylim
16431644 """
16441645
1645- if len (v ) == len (kwargs ) == 0 :
1646+ if len (args ) == len (kwargs ) == 0 :
16461647 xmin , xmax = self .get_xlim ()
16471648 ymin , ymax = self .get_ylim ()
16481649 return xmin , xmax , ymin , ymax
16491650
16501651 emit = kwargs .get ('emit' , True )
16511652
1652- if len (v ) == 1 and isinstance (v [0 ], str ):
1653- s = v [0 ].lower ()
1653+ if len (args ) == 1 and isinstance (args [0 ], str ):
1654+ s = args [0 ].lower ()
16541655 if s == 'on' :
16551656 self .set_axis_on ()
16561657 elif s == 'off' :
@@ -1695,7 +1696,7 @@ def axis(self, *v, **kwargs):
16951696 return xmin , xmax , ymin , ymax
16961697
16971698 try :
1698- v [0 ]
1699+ args [0 ]
16991700 except IndexError :
17001701 xmin = kwargs .get ('xmin' , None )
17011702 xmax = kwargs .get ('xmax' , None )
@@ -1712,9 +1713,18 @@ def axis(self, *v, **kwargs):
17121713 ymin , ymax = self .set_ylim (ymin , ymax , emit = emit , auto = auto )
17131714 return xmin , xmax , ymin , ymax
17141715
1715- v = v [0 ]
1716+ v = args [0 ]
1717+ if isinstance (v , bool ):
1718+ if v :
1719+ self .set_axis_on ()
1720+ else :
1721+ self .set_axis_off ()
1722+ xmin , xmax = self .get_xlim ()
1723+ ymin , ymax = self .get_ylim ()
1724+ return xmin , xmax , ymin , ymax
1725+
17161726 if len (v ) != 4 :
1717- raise ValueError ('v must contain [xmin xmax ymin ymax]' )
1727+ raise ValueError ('args must contain [xmin xmax ymin ymax]' )
17181728
17191729 self .set_xlim ([v [0 ], v [1 ]], emit = emit , auto = False )
17201730 self .set_ylim ([v [2 ], v [3 ]], emit = emit , auto = False )
0 commit comments