|
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 |
|
@@ -1357,7 +1358,7 @@ def get_offset_text(self): |
1357 | 1358 |
|
1358 | 1359 | def get_pickradius(self): |
1359 | 1360 | """Return the depth of the axis used by the picker.""" |
1360 | | - return self.pickradius |
| 1361 | + return self._pickradius |
1361 | 1362 |
|
1362 | 1363 | def get_majorticklabels(self): |
1363 | 1364 | """Return this Axis' major tick labels, as a list of `~.text.Text`.""" |
@@ -1831,9 +1832,17 @@ def set_pickradius(self, pickradius): |
1831 | 1832 |
|
1832 | 1833 | Parameters |
1833 | 1834 | ---------- |
1834 | | - pickradius : float |
| 1835 | + pickradius : float |
| 1836 | + The acceptance radius for containment tests. |
| 1837 | + See also `.Axis.contains`. |
1835 | 1838 | """ |
1836 | | - self.pickradius = pickradius |
| 1839 | + if not isinstance(pickradius, Number) or pickradius < 0: |
| 1840 | + raise ValueError("pick radius should be a distance") |
| 1841 | + self._pickradius = pickradius |
| 1842 | + |
| 1843 | + pickradius = property( |
| 1844 | + get_pickradius, set_pickradius, doc="The acceptance radius for " |
| 1845 | + "containment tests. See also `.Axis.contains`.") |
1837 | 1846 |
|
1838 | 1847 | # Helper for set_ticklabels. Defining it here makes it picklable. |
1839 | 1848 | @staticmethod |
@@ -2217,8 +2226,8 @@ def contains(self, mouseevent): |
2217 | 2226 | return False, {} |
2218 | 2227 | (l, b), (r, t) = self.axes.transAxes.transform([(0, 0), (1, 1)]) |
2219 | 2228 | inaxis = 0 <= xaxes <= 1 and ( |
2220 | | - b - self.pickradius < y < b or |
2221 | | - t < y < t + self.pickradius) |
| 2229 | + b - self._pickradius < y < b or |
| 2230 | + t < y < t + self._pickradius) |
2222 | 2231 | return inaxis, {} |
2223 | 2232 |
|
2224 | 2233 | def set_label_position(self, position): |
@@ -2470,8 +2479,8 @@ def contains(self, mouseevent): |
2470 | 2479 | return False, {} |
2471 | 2480 | (l, b), (r, t) = self.axes.transAxes.transform([(0, 0), (1, 1)]) |
2472 | 2481 | inaxis = 0 <= yaxes <= 1 and ( |
2473 | | - l - self.pickradius < x < l or |
2474 | | - r < x < r + self.pickradius) |
| 2482 | + l - self._pickradius < x < l or |
| 2483 | + r < x < r + self._pickradius) |
2475 | 2484 | return inaxis, {} |
2476 | 2485 |
|
2477 | 2486 | def set_label_position(self, position): |
|
0 commit comments