Skip to content

Commit 23b5240

Browse files
committed
DOC : cleaned up/clarified docstring
1 parent 01da70d commit 23b5240

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

lib/matplotlib/contour.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -548,9 +548,11 @@ def add_label_clabeltext(self, x, y, rotation, lev, cvalue):
548548
def add_label_near(self, x, y, inline=True, inline_spacing=5,
549549
transform=None):
550550
"""
551-
Add a label near the point (x, y) of the given transform.
552-
If transform is None, data transform is used. If transform is
553-
False, IdentityTransform is used.
551+
Add a label near the point (x, y). If transform is None
552+
(default), (x, y) is in data coordinates; if transform is
553+
False, (x, y) is in display coordinates; otherwise, the
554+
specified transform will be used to translate (x, y) into
555+
display coordinates.
554556
555557
*inline*:
556558
controls whether the underlying contour is removed or
@@ -562,15 +564,11 @@ def add_label_near(self, x, y, inline=True, inline_spacing=5,
562564
exact for labels at locations where the contour is
563565
straight, less so for labels on curved contours.
564566
"""
565-
# if 'do the default thing' use the axes data transform
567+
566568
if transform is None:
567569
transform = self.ax.transData
568570

569-
# if transform is 'falsey' don't do any transform (this is a
570-
# really awful API but is what we have)
571571
if transform:
572-
# The point of this transform is to get the location
573-
# of label position into screen units
574572
x, y = transform.transform_point((x, y))
575573

576574
# find the nearest contour _in screen units_
@@ -586,8 +584,7 @@ def add_label_near(self, x, y, inline=True, inline_spacing=5,
586584
active_path = paths[segmin]
587585
# grab it's verticies
588586
lc = active_path.vertices
589-
# sort out where the new vertex should be added in the path's data
590-
# units
587+
# sort out where the new vertex should be added data-units
591588
xcmin = self.ax.transData.inverted().transform_point([xmin, ymin])
592589
# if there isn't a vertex close enough
593590
if not np.allclose(xcmin, lc[imin]):

0 commit comments

Comments
 (0)