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

Commit13b4555

Browse files
committed
Fix containment and subslice optim. for steps.
#6497 set the `_path` attribute of Line2D to the actually drawn patheven if the drawstyle is `steps-*`; however containment tests and thesubslice optimization for very long paths were not updated accordingly(see#6615). This patch fixes the issues.Note that `contains` returns, for events in a horizontal segment of a"steps-mid" drawstyle plot, the index of the point in the segment,regardless of whether the event occured to the left or the right ofthat point.
1 parent5de9c44 commit13b4555

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

‎lib/matplotlib/lines.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,8 @@ def contains(self, mouseevent):
479479
else:
480480
# If line, return the nearby segment(s)
481481
ind=segment_hits(mouseevent.x,mouseevent.y,xt,yt,pixels)
482+
ifself._drawstyle.startswith("steps"):
483+
ind//=2
482484

483485
ind+=self.ind_offset
484486

@@ -680,7 +682,8 @@ def recache(self, always=False):
680682
else:
681683
interpolation_steps=1
682684
xy=STEP_LOOKUP_MAP[self._drawstyle](*self._xy.T)
683-
self._path=Path(np.asarray(xy).T,None,interpolation_steps)
685+
self._path=Path(np.asarray(xy).T,
686+
_interpolation_steps=interpolation_steps)
684687
self._transformed_path=None
685688
self._invalidx=False
686689
self._invalidy=False
@@ -693,8 +696,9 @@ def _transform_path(self, subslice=None):
693696
"""
694697
# Masked arrays are now handled by the Path class itself
695698
ifsubsliceisnotNone:
696-
_steps=self._path._interpolation_steps
697-
_path=Path(self._xy[subslice, :],_interpolation_steps=_steps)
699+
xy=STEP_LOOKUP_MAP[self._drawstyle](*self._xy[subslice, :].T)
700+
_path=Path(np.asarray(xy).T,
701+
_interpolation_steps=self._path._interpolation_steps)
698702
else:
699703
_path=self._path
700704
self._transformed_path=TransformedPath(_path,self.get_transform())

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp