From 989b2b73ac93990a3bc3cc778c01aa2bc447badc Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sun, 12 Jan 2020 16:24:03 +0100 Subject: [PATCH] Numpydoc ContourSet.find_nearest_contour. --- lib/matplotlib/contour.py | 42 ++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/lib/matplotlib/contour.py b/lib/matplotlib/contour.py index 942151b7a829..ddf769b34173 100644 --- a/lib/matplotlib/contour.py +++ b/lib/matplotlib/contour.py @@ -1297,24 +1297,34 @@ def set_alpha(self, alpha): def find_nearest_contour(self, x, y, indices=None, pixel=True): """ - Finds contour that is closest to a point. Defaults to - measuring distance in pixels (screen space - useful for manual - contour labeling), but this can be controlled via a keyword - argument. + Find the point in the contour plot that is closest to ``(x, y)``. - Returns a tuple containing the contour, segment, index of - segment, x & y of segment point and distance to minimum point. - - Optional keyword arguments: - - *indices*: - Indexes of contour levels to consider when looking for - nearest point. Defaults to using all levels. - - *pixel*: - If *True*, measure distance in pixel space, if not, measure - distance in axes space. Defaults to *True*. + Parameters + ---------- + x, y: float + The reference point. + indices : list of int or None, default: None + Indices of contour levels to consider. If None (the default), all + levels are considered. + pixel : bool, default: True + If *True*, measure distance in pixel (screen) space, which is + useful for manual contour labeling; else, measure distance in axes + space. + Returns + ------- + contour : `.Collection` + The contour that is closest to ``(x, y)``. + segment : int + The index of the `.Path` in *contour* that is closest to + ``(x, y)``. + index : int + The index of the path segment in *segment* that is closest to + ``(x, y)``. + xmin, ymin : float + The point in the contour plot that is closest to ``(x, y)``. + d : float + The distance from ``(xmin, ymin)`` to ``(x, y)``. """ # This function uses a method that is probably quite