Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b52aad8

Browse filesBrowse files
authored
Merge pull request #19336 from anntzer/pickradius
Revert "Deprecate setting Line2D's pickradius via set_picker."
2 parents b5e714a + 0237632 commit b52aad8
Copy full SHA for b52aad8

File tree

3 files changed

+25
-13
lines changed
Filter options

3 files changed

+25
-13
lines changed
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Setting a Line2D's pickradius via ``set_picker`` is undeprecated
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
This cancels the deprecation introduced in Matplotlib 3.3.0.

‎lib/matplotlib/artist.py

Copy file name to clipboardExpand all lines: lib/matplotlib/artist.py
+9-6Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ def set_picker(self, picker):
539539
540540
Parameters
541541
----------
542-
picker : None or bool or callable
542+
picker : None or bool or float or callable
543543
This can be one of the following:
544544
545545
- *None*: Picking is disabled for this artist (default).
@@ -548,6 +548,14 @@ def set_picker(self, picker):
548548
artist will fire a pick event if the mouse event is over
549549
the artist.
550550
551+
- A float: If picker is a number it is interpreted as an
552+
epsilon tolerance in points and the artist will fire
553+
off an event if its data is within epsilon of the mouse
554+
event. For some artists like lines and patch collections,
555+
the artist may provide additional data to the pick event
556+
that is generated, e.g., the indices of the data within
557+
epsilon of the pick event
558+
551559
- A function: If picker is callable, it is a user supplied
552560
function which determines whether the artist is hit by the
553561
mouse event::
@@ -557,11 +565,6 @@ def set_picker(self, picker):
557565
to determine the hit test. if the mouse event is over the
558566
artist, return *hit=True* and props is a dictionary of
559567
properties you want added to the PickEvent attributes.
560-
561-
- *deprecated*: For `.Line2D` only, *picker* can also be a float
562-
that sets the tolerance for checking whether an event occurred
563-
"on" the line; this is deprecated. Use `.Line2D.set_pickradius`
564-
instead.
565568
"""
566569
self._picker = picker
567570

‎lib/matplotlib/lines.py

Copy file name to clipboardExpand all lines: lib/matplotlib/lines.py
+13-7Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,8 @@ def __init__(self, xdata, ydata,
397397
self.update(kwargs)
398398
self.pickradius = pickradius
399399
self.ind_offset = 0
400+
if isinstance(self._picker, Number):
401+
self.pickradius = self._picker
400402

401403
self._xorig = np.asarray([])
402404
self._yorig = np.asarray([])
@@ -601,13 +603,17 @@ def get_markevery(self):
601603
return self._markevery
602604

603605
def set_picker(self, p):
604-
# docstring inherited
605-
if isinstance(p, Number) and not isinstance(p, bool):
606-
# After deprecation, the whole method can be deleted and inherited.
607-
_api.warn_deprecated(
608-
"3.3", message="Setting the line's pick radius via set_picker "
609-
"is deprecated since %(since)s and will be removed "
610-
"%(removal)s; use set_pickradius instead.")
606+
"""
607+
Sets the event picker details for the line.
608+
609+
Parameters
610+
----------
611+
p : float or callable[[Artist, Event], Tuple[bool, dict]]
612+
If a float, it is used as the pick radius in points.
613+
"""
614+
if callable(p):
615+
self._contains = p
616+
else:
611617
self.pickradius = p
612618
self._picker = p
613619

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.