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

Revert "Deprecate setting Line2D's pickradius via set_picker." #19336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions 3 doc/api/next_api_changes/deprecations/19336-AL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Setting a Line2D's pickradius via ``set_picker`` is undeprecated
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This cancels the deprecation introduced in Matplotlib 3.3.0.
15 changes: 9 additions & 6 deletions 15 lib/matplotlib/artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ def set_picker(self, picker):

Parameters
----------
picker : None or bool or callable
picker : None or bool or float or callable
This can be one of the following:

- *None*: Picking is disabled for this artist (default).
Expand All @@ -548,6 +548,14 @@ def set_picker(self, picker):
artist will fire a pick event if the mouse event is over
the artist.

- A float: If picker is a number it is interpreted as an
epsilon tolerance in points and the artist will fire
off an event if its data is within epsilon of the mouse
event. For some artists like lines and patch collections,
the artist may provide additional data to the pick event
that is generated, e.g., the indices of the data within
epsilon of the pick event

- A function: If picker is callable, it is a user supplied
function which determines whether the artist is hit by the
mouse event::
Expand All @@ -557,11 +565,6 @@ def set_picker(self, picker):
to determine the hit test. if the mouse event is over the
artist, return *hit=True* and props is a dictionary of
properties you want added to the PickEvent attributes.

- *deprecated*: For `.Line2D` only, *picker* can also be a float
that sets the tolerance for checking whether an event occurred
"on" the line; this is deprecated. Use `.Line2D.set_pickradius`
instead.
"""
self._picker = picker

Expand Down
20 changes: 13 additions & 7 deletions 20 lib/matplotlib/lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@ def __init__(self, xdata, ydata,
self.update(kwargs)
self.pickradius = pickradius
self.ind_offset = 0
if isinstance(self._picker, Number):
self.pickradius = self._picker

self._xorig = np.asarray([])
self._yorig = np.asarray([])
Expand Down Expand Up @@ -601,13 +603,17 @@ def get_markevery(self):
return self._markevery

def set_picker(self, p):
# docstring inherited
if isinstance(p, Number) and not isinstance(p, bool):
# After deprecation, the whole method can be deleted and inherited.
_api.warn_deprecated(
"3.3", message="Setting the line's pick radius via set_picker "
"is deprecated since %(since)s and will be removed "
"%(removal)s; use set_pickradius instead.")
"""
Sets the event picker details for the line.

Parameters
----------
p : float or callable[[Artist, Event], Tuple[bool, dict]]
If a float, it is used as the pick radius in points.
"""
if callable(p):
self._contains = p
else:
self.pickradius = p
self._picker = p

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.