@@ -1661,12 +1661,12 @@ def view_limits(self, vmin, vmax):
1661
1661
return mtransforms .nonsingular (vmin , vmax )
1662
1662
1663
1663
1664
- # @cbook.deprecated("3.1")
1664
+ @cbook .deprecated ("3.1" )
1665
1665
def closeto (x , y ):
1666
1666
return abs (x - y ) < 1e-10
1667
1667
1668
1668
1669
- # @cbook.deprecated("3.1")
1669
+ @cbook .deprecated ("3.1" )
1670
1670
class Base (object ):
1671
1671
'this solution has some hacks to deal with floating point inaccuracies'
1672
1672
def __init__ (self , base ):
@@ -1710,17 +1710,16 @@ def get_base(self):
1710
1710
1711
1711
class MultipleLocator (Locator ):
1712
1712
"""
1713
- Set a tick on every integer that is multiple of base in the
1714
- view interval
1713
+ Set a tick on each integer multiple of a base within the view interval.
1715
1714
"""
1716
1715
1717
1716
def __init__ (self , base = 1.0 ):
1718
- self ._base = Base (base )
1717
+ self ._edge = _Edge_integer (base , 0 )
1719
1718
1720
1719
def set_params (self , base ):
1721
1720
"""Set parameters within this locator."""
1722
1721
if base is not None :
1723
- self ._base = base
1722
+ self ._edge = _Edge_integer ( base , 0 )
1724
1723
1725
1724
def __call__ (self ):
1726
1725
'Return the locations of the ticks'
@@ -1730,20 +1729,20 @@ def __call__(self):
1730
1729
def tick_values (self , vmin , vmax ):
1731
1730
if vmax < vmin :
1732
1731
vmin , vmax = vmax , vmin
1733
- vmin = self ._base . ge ( vmin )
1734
- base = self ._base . get_base ()
1735
- n = (vmax - vmin + 0.001 * base ) // base
1736
- locs = vmin - base + np .arange (n + 3 ) * base
1732
+ step = self ._edge . step
1733
+ vmin = self ._edge . ge ( vmin ) * step
1734
+ n = (vmax - vmin + 0.001 * step ) // step
1735
+ locs = vmin - step + np .arange (n + 3 ) * step
1737
1736
return self .raise_if_exceeds (locs )
1738
1737
1739
1738
def view_limits (self , dmin , dmax ):
1740
1739
"""
1741
1740
Set the view limits to the nearest multiples of base that
1742
- contain the data
1741
+ contain the data.
1743
1742
"""
1744
1743
if rcParams ['axes.autolimit_mode' ] == 'round_numbers' :
1745
- vmin = self ._base .le (dmin )
1746
- vmax = self ._base .ge (dmax )
1744
+ vmin = self ._edge .le (dmin ) * self . _edge . step
1745
+ vmax = self ._base .ge (dmax ) * self . _edge . step
1747
1746
if vmin == vmax :
1748
1747
vmin -= 1
1749
1748
vmax += 1
@@ -1767,7 +1766,7 @@ def scale_range(vmin, vmax, n=1, threshold=100):
1767
1766
1768
1767
class _Edge_integer :
1769
1768
"""
1770
- Helper for MaxNLocator.
1769
+ Helper for MaxNLocator, MultipleLocator, etc .
1771
1770
1772
1771
Take floating point precision limitations into account when calculating
1773
1772
tick locations as integer multiples of a step.
@@ -1794,14 +1793,14 @@ def closeto(self, ms, edge):
1794
1793
return abs (ms - edge ) < tol
1795
1794
1796
1795
def le (self , x ):
1797
- 'Return the largest n: n*base <= x'
1796
+ 'Return the largest n: n*step <= x. '
1798
1797
d , m = _divmod (x , self .step )
1799
1798
if self .closeto (m / self .step , 1 ):
1800
1799
return (d + 1 )
1801
1800
return d
1802
1801
1803
1802
def ge (self , x ):
1804
- 'Return the smallest n: n*base >= x'
1803
+ 'Return the smallest n: n*step >= x. '
1805
1804
d , m = _divmod (x , self .step )
1806
1805
if self .closeto (m / self .step , 0 ):
1807
1806
return d
0 commit comments