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