MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / closest

Method closest

lib/matplotlib/widgets.py:3270–3278  ·  view source on GitHub ↗

Return index and pixel distance to closest index.

(self, x, y)

Source from the content-addressed store, hash-verified

3268 self._markers.set_animated(val)
3269
3270 def closest(self, x, y):
3271 """Return index and pixel distance to closest index."""
3272 pts = np.column_stack([self.x, self.y])
3273 # Transform data coordinates to pixel coordinates.
3274 pts = self.ax.transData.transform(pts)
3275 diff = pts - [x, y]
3276 dist = np.hypot(*diff.T)
3277 min_index = np.argmin(dist)
3278 return min_index, dist[min_index]
3279
3280
3281_RECTANGLESELECTOR_PARAMETERS_DOCSTRING = \

Callers 4

_hoverMethod · 0.45
_set_active_handleMethod · 0.45
_set_active_handleMethod · 0.45
_pressMethod · 0.45

Calls 1

transformMethod · 0.45

Tested by

no test coverage detected