Skip to content

Commit

Permalink
Omit MOVETO lines from nearest contour logic
Browse files Browse the repository at this point in the history
Closes #27333
  • Loading branch information
ksunden committed Nov 16, 2023
1 parent b16031c commit a48e425
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions lib/matplotlib/contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -1339,15 +1339,18 @@ def _find_nearest_contour(self, xy, indices=None):

for idx_level in indices:
path = self._paths[idx_level]
if not len(path.vertices):
continue
lc = self.get_transform().transform(path.vertices)
d2, proj, leg = _find_closest_point_on_path(lc, xy)
if d2 < d2min:
d2min = d2
idx_level_min = idx_level
idx_vtx_min = leg[1]
proj_min = proj
idx_vtx_start = 0
for subpath in path._iter_connected_components():
if not len(subpath.vertices):
continue
lc = self.get_transform().transform(subpath.vertices)
d2, proj, leg = _find_closest_point_on_path(lc, xy)
if d2 < d2min:
d2min = d2
idx_level_min = idx_level
idx_vtx_min = leg[1] + idx_vtx_start
proj_min = proj
idx_vtx_start += len(subpath)

return idx_level_min, idx_vtx_min, proj_min

Expand Down

0 comments on commit a48e425

Please sign in to comment.