|
5 | 5 | import datetime
|
6 | 6 | import functools
|
7 | 7 | import logging
|
| 8 | +from numbers import Number |
8 | 9 |
|
9 | 10 | import numpy as np
|
10 | 11 |
|
@@ -680,7 +681,7 @@ def __init__(self, axes, pickradius=15):
|
680 | 681 |
|
681 | 682 | self.labelpad = mpl.rcParams['axes.labelpad']
|
682 | 683 |
|
683 |
| - self.pickradius = pickradius |
| 684 | + self._pickradius = pickradius |
684 | 685 |
|
685 | 686 | # Initialize here for testing; later add API
|
686 | 687 | self._major_tick_kw = dict()
|
@@ -1308,7 +1309,7 @@ def get_offset_text(self):
|
1308 | 1309 |
|
1309 | 1310 | def get_pickradius(self):
|
1310 | 1311 | """Return the depth of the axis used by the picker."""
|
1311 |
| - return self.pickradius |
| 1312 | + return self._pickradius |
1312 | 1313 |
|
1313 | 1314 | def get_majorticklabels(self):
|
1314 | 1315 | """Return this Axis' major tick labels, as a list of `~.text.Text`."""
|
@@ -1782,9 +1783,17 @@ def set_pickradius(self, pickradius):
|
1782 | 1783 |
|
1783 | 1784 | Parameters
|
1784 | 1785 | ----------
|
1785 |
| - pickradius : float |
| 1786 | + pickradius : float |
| 1787 | + The acceptance radius for containment tests. |
| 1788 | + See also `.Axis.contains`. |
1786 | 1789 | """
|
1787 |
| - self.pickradius = pickradius |
| 1790 | + if not isinstance(pickradius, Number) or pickradius < 0: |
| 1791 | + raise ValueError("pick radius should be a distance") |
| 1792 | + self._pickradius = pickradius |
| 1793 | + |
| 1794 | + pickradius = property( |
| 1795 | + get_pickradius, set_pickradius, doc="The acceptance radius for " |
| 1796 | + "containment tests. See also `.Axis.contains`.") |
1788 | 1797 |
|
1789 | 1798 | # Helper for set_ticklabels. Defining it here makes it picklable.
|
1790 | 1799 | @staticmethod
|
@@ -2168,8 +2177,8 @@ def contains(self, mouseevent):
|
2168 | 2177 | return False, {}
|
2169 | 2178 | (l, b), (r, t) = self.axes.transAxes.transform([(0, 0), (1, 1)])
|
2170 | 2179 | inaxis = 0 <= xaxes <= 1 and (
|
2171 |
| - b - self.pickradius < y < b or |
2172 |
| - t < y < t + self.pickradius) |
| 2180 | + b - self._pickradius < y < b or |
| 2181 | + t < y < t + self._pickradius) |
2173 | 2182 | return inaxis, {}
|
2174 | 2183 |
|
2175 | 2184 | def set_label_position(self, position):
|
@@ -2420,8 +2429,8 @@ def contains(self, mouseevent):
|
2420 | 2429 | return False, {}
|
2421 | 2430 | (l, b), (r, t) = self.axes.transAxes.transform([(0, 0), (1, 1)])
|
2422 | 2431 | inaxis = 0 <= yaxes <= 1 and (
|
2423 |
| - l - self.pickradius < x < l or |
2424 |
| - r < x < r + self.pickradius) |
| 2432 | + l - self._pickradius < x < l or |
| 2433 | + r < x < r + self._pickradius) |
2425 | 2434 | return inaxis, {}
|
2426 | 2435 |
|
2427 | 2436 | def set_label_position(self, position):
|
|
0 commit comments