Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit02e93e2

Browse files
authored
Merge pull request#23196 from oscargus/pickradiusunification
Unify set_pickradius argument
2 parents535c953 +91f47d6 commit02e93e2

File tree

4 files changed

+31
-19
lines changed

4 files changed

+31
-19
lines changed

‎doc/api/axis_api.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ Interactive
150150
:nosignatures:
151151

152152
Axis.contains
153+
Axis.pickradius
153154
Axis.get_pickradius
154155
Axis.set_pickradius
155156

‎lib/matplotlib/axis.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
importdatetime
66
importfunctools
77
importlogging
8+
fromnumbersimportNumber
89

910
importnumpyasnp
1011

@@ -1357,7 +1358,7 @@ def get_offset_text(self):
13571358

13581359
defget_pickradius(self):
13591360
"""Return the depth of the axis used by the picker."""
1360-
returnself.pickradius
1361+
returnself._pickradius
13611362

13621363
defget_majorticklabels(self):
13631364
"""Return this Axis' major tick labels, as a list of `~.text.Text`."""
@@ -1831,9 +1832,17 @@ def set_pickradius(self, pickradius):
18311832
18321833
Parameters
18331834
----------
1834-
pickradius : float
1835+
pickradius : float
1836+
The acceptance radius for containment tests.
1837+
See also `.Axis.contains`.
18351838
"""
1836-
self.pickradius=pickradius
1839+
ifnotisinstance(pickradius,Number)orpickradius<0:
1840+
raiseValueError("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`.")
18371846

18381847
# Helper for set_ticklabels. Defining it here makes it picklable.
18391848
@staticmethod
@@ -2217,8 +2226,8 @@ def contains(self, mouseevent):
22172226
returnFalse, {}
22182227
(l,b), (r,t)=self.axes.transAxes.transform([(0,0), (1,1)])
22192228
inaxis=0<=xaxes<=1and (
2220-
b-self.pickradius<y<bor
2221-
t<y<t+self.pickradius)
2229+
b-self._pickradius<y<bor
2230+
t<y<t+self._pickradius)
22222231
returninaxis, {}
22232232

22242233
defset_label_position(self,position):
@@ -2470,8 +2479,8 @@ def contains(self, mouseevent):
24702479
returnFalse, {}
24712480
(l,b), (r,t)=self.axes.transAxes.transform([(0,0), (1,1)])
24722481
inaxis=0<=yaxes<=1and (
2473-
l-self.pickradius<x<lor
2474-
r<x<r+self.pickradius)
2482+
l-self._pickradius<x<lor
2483+
r<x<r+self._pickradius)
24752484
returninaxis, {}
24762485

24772486
defset_label_position(self,position):

‎lib/matplotlib/collections.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,16 +419,17 @@ def draw(self, renderer):
419419
renderer.close_group(self.__class__.__name__)
420420
self.stale=False
421421

422-
defset_pickradius(self,pr):
422+
@_api.rename_parameter("3.6","pr","pickradius")
423+
defset_pickradius(self,pickradius):
423424
"""
424425
Set the pick radius used for containment tests.
425426
426427
Parameters
427428
----------
428-
pr : float
429+
pickradius : float
429430
Pick radius, in points.
430431
"""
431-
self._pickradius=pr
432+
self._pickradius=pickradius
432433

433434
defget_pickradius(self):
434435
returnself._pickradius

‎lib/matplotlib/lines.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -390,11 +390,11 @@ def __init__(self, xdata, ydata,
390390
# update kwargs before updating data to give the caller a
391391
# chance to init axes (and hence unit support)
392392
self._internal_update(kwargs)
393-
self.pickradius=pickradius
393+
self._pickradius=pickradius
394394
self.ind_offset=0
395395
if (isinstance(self._picker,Number)and
396396
notisinstance(self._picker,bool)):
397-
self.pickradius=self._picker
397+
self._pickradius=self._picker
398398

399399
self._xorig=np.asarray([])
400400
self._yorig=np.asarray([])
@@ -455,9 +455,9 @@ def contains(self, mouseevent):
455455
# Convert pick radius from points to pixels
456456
ifself.figureisNone:
457457
_log.warning('no figure set when check if mouse is on line')
458-
pixels=self.pickradius
458+
pixels=self._pickradius
459459
else:
460-
pixels=self.figure.dpi/72.*self.pickradius
460+
pixels=self.figure.dpi/72.*self._pickradius
461461

462462
# The math involved in checking for containment (here and inside of
463463
# segment_hits) assumes that it is OK to overflow, so temporarily set
@@ -488,20 +488,21 @@ def get_pickradius(self):
488488
"""
489489
returnself._pickradius
490490

491-
defset_pickradius(self,d):
491+
@_api.rename_parameter("3.6","d","pickradius")
492+
defset_pickradius(self,pickradius):
492493
"""
493494
Set the pick radius used for containment tests.
494495
495496
See `.contains` for more details.
496497
497498
Parameters
498499
----------
499-
d : float
500+
pickradius : float
500501
Pick radius, in points.
501502
"""
502-
ifnotisinstance(d,Number)ord<0:
503+
ifnotisinstance(pickradius,Number)orpickradius<0:
503504
raiseValueError("pick radius should be a distance")
504-
self._pickradius=d
505+
self._pickradius=pickradius
505506

506507
pickradius=property(get_pickradius,set_pickradius)
507508

@@ -612,7 +613,7 @@ def set_picker(self, p):
612613
ifcallable(p):
613614
self._contains=p
614615
else:
615-
self.pickradius=p
616+
self.set_pickradius(p)
616617
self._picker=p
617618

618619
defget_bbox(self):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp