@@ -1588,7 +1588,7 @@ def apply_aspect(self, position=None):
1588
1588
else :
1589
1589
self .set_xbound ((x0 , x1 ))
1590
1590
1591
- def axis (self , * v , ** kwargs ):
1591
+ def axis (self , * args , ** kwargs ):
1592
1592
"""
1593
1593
Convenience method to get or set some axis properties.
1594
1594
@@ -1605,14 +1605,15 @@ def axis(self, *v, **kwargs):
1605
1605
The axis limits to be set. Either none or all of the limits must
1606
1606
be given.
1607
1607
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:
1610
1611
1611
1612
======== ==========================================================
1612
1613
Value Description
1613
1614
======== ==========================================================
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``.
1616
1617
'equal' Set equal scaling (i.e., make circles circular) by
1617
1618
changing axis limits.
1618
1619
'scaled' Set equal scaling (i.e., make circles circular) by
@@ -1641,15 +1642,15 @@ def axis(self, *v, **kwargs):
1641
1642
matplotlib.axes.Axes.set_ylim
1642
1643
"""
1643
1644
1644
- if len (v ) == len (kwargs ) == 0 :
1645
+ if len (args ) == len (kwargs ) == 0 :
1645
1646
xmin , xmax = self .get_xlim ()
1646
1647
ymin , ymax = self .get_ylim ()
1647
1648
return xmin , xmax , ymin , ymax
1648
1649
1649
1650
emit = kwargs .get ('emit' , True )
1650
1651
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 ()
1653
1654
if s == 'on' :
1654
1655
self .set_axis_on ()
1655
1656
elif s == 'off' :
@@ -1694,7 +1695,7 @@ def axis(self, *v, **kwargs):
1694
1695
return xmin , xmax , ymin , ymax
1695
1696
1696
1697
try :
1697
- v [0 ]
1698
+ args [0 ]
1698
1699
except IndexError :
1699
1700
xmin = kwargs .get ('xmin' , None )
1700
1701
xmax = kwargs .get ('xmax' , None )
@@ -1711,9 +1712,18 @@ def axis(self, *v, **kwargs):
1711
1712
ymin , ymax = self .set_ylim (ymin , ymax , emit = emit , auto = auto )
1712
1713
return xmin , xmax , ymin , ymax
1713
1714
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
+
1715
1725
if len (v ) != 4 :
1716
- raise ValueError ('v must contain [xmin xmax ymin ymax]' )
1726
+ raise ValueError ('args must contain [xmin xmax ymin ymax]' )
1717
1727
1718
1728
self .set_xlim ([v [0 ], v [1 ]], emit = emit , auto = False )
1719
1729
self .set_ylim ([v [2 ], v [3 ]], emit = emit , auto = False )
0 commit comments