@@ -1409,13 +1409,13 @@ def find_nearest_contour(self, x, y, indices=None, pixel=True):
1409
1409
1410
1410
Returns
1411
1411
-------
1412
- contour : `.Collection`
1413
- The contour that is closest to ``(x, y)``.
1412
+ path : int
1413
+ The index of the path that is closest to ``(x, y)``.
1414
1414
segment : int
1415
- The index of the `.Path` in *contour* that is closest to
1415
+ The index within that closest path of the segment that is closest to
1416
1416
``(x, y)``.
1417
1417
index : int
1418
- The index of the path segment in * segment* that is closest to
1418
+ The index of the vertices within that segment that are closest to
1419
1419
``(x, y)``.
1420
1420
xmin, ymin : float
1421
1421
The point in the contour plot that is closest to ``(x, y)``.
@@ -1434,8 +1434,9 @@ def find_nearest_contour(self, x, y, indices=None, pixel=True):
1434
1434
if self .filled :
1435
1435
raise ValueError ("Method does not support filled contours." )
1436
1436
1437
+ paths = self .get_paths ()
1437
1438
if indices is None :
1438
- indices = range (len (self . collections ))
1439
+ indices = range (len (paths ))
1439
1440
1440
1441
d2min = np .inf
1441
1442
conmin = None
@@ -1445,14 +1446,15 @@ def find_nearest_contour(self, x, y, indices=None, pixel=True):
1445
1446
ymin = None
1446
1447
1447
1448
point = np .array ([x , y ])
1449
+ trans = self .get_transform ()
1448
1450
1449
1451
for icon in indices :
1450
- con = self .collections [icon ]
1451
- trans = con .get_transform ()
1452
- paths = con .get_paths ()
1452
+ path = paths [icon ]
1453
1453
1454
- for segNum , linepath in enumerate (paths ):
1454
+ for segNum , linepath in enumerate (path . _iter_connected_components () ):
1455
1455
lc = linepath .vertices
1456
+ if lc .size == 0 :
1457
+ continue
1456
1458
# transfer all data points to screen coordinates if desired
1457
1459
if pixel :
1458
1460
lc = trans .transform (lc )
0 commit comments