8000 Backport PR #14459: Cleanup docstring of DraggableBase. · matplotlib/matplotlib@c45c457 · GitHub
[go: up one dir, main page]

Skip to content

Commit c45c457

Browse files
dstansbyMeeseeksDev[bot]
authored andcommitted
Backport PR #14459: Cleanup docstring of DraggableBase.
1 parent 76ff8d0 commit c45c457

File tree

1 file changed

+23
-25
lines changed

1 file changed

+23
-25
lines changed

lib/matplotlib/offsetbox.py

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,35 +1596,35 @@ def draw(self, renderer):
15961596

15971597
class DraggableBase(object):
15981598
"""
1599-
helper code for a draggable artist (legend, offsetbox)
1600-
The derived class must override following two method.
1599+
Helper base class for a draggable artist (legend, offsetbox).
16011600
1602-
def save_offset(self):
1603-
pass
1601+
Derived classes must override the following methods::
16041602
1605-
def update_offset(self, dx, dy):
1606-
pass
1603+
def save_offset(self):
1604+
'''
1605+
Called when the object is picked for dragging; should save the
1606+
reference position of the artist.
1607+
'''
16071608
1608-
*save_offset* is called when the object is picked for dragging and it
1609-
is meant to save reference position of the artist.
1609+
def update_offset(self, dx, dy):
1610+
'''
1611+
Called during the dragging; (*dx*, *dy*) is the pixel offset from
1612+
the point where the mouse drag started.
1613+
'''
16101614
1611-
*update_offset* is called during the dragging. dx and dy is the pixel
1612-
offset from the point where the mouse drag started.
1615+
Optionally, you may override the following methods::
16131616
1614-
Optionally you may override following two methods.
1617+
def artist_picker(self, artist, evt):
1618+
'''The picker method that will be used.'''
1619+
return self.ref_artist.contains(evt)
16151620
1616-
def artist_picker(self, artist, evt):
1617-
return self.ref_artist.contains(evt)
1621+
def finalize_offset(self):
1622+
'''Called when the mouse is released.'''
16181623
1619-
def finalize_offset(self):
1620-
pass
1621-
1622-
*artist_picker* is a picker method that will be
1623-
used. *finalize_offset* is called when the mouse is released. In
1624-
current implementation of DraggableLegend and DraggableAnnotation,
1625-
*update_offset* places the artists simply in display
1626-
coordinates. And *finalize_offset* recalculate their position in
1627-
the normalized axes coordinate and set a relevant attribute.
1624+
In the current implementation of `DraggableLegend` and
1625+
`DraggableAnnotation`, `update_offset` places the artists in display
1626+
coordinates, and `finalize_offset` recalculates their position in axes
1627+
coordinate and set a relevant attribute.
16281628
"""
16291629

16301630
def __init__(self, ref_artist, use_blit=False):
@@ -1694,7 +1694,7 @@ def _check_still_parented(self):
16941694
return True
16951695

16961696
def disconnect(self):
1697-
"""disconnect the callbacks"""
1697+
"""Disconnect the callbacks."""
16981698
for cid in self.cids:
16991699
self.canvas.mpl_disconnect(cid)
17001700
try:
@@ -1735,13 +1735,11 @@ def update_offset(self, dx, dy):
17351735
self.offsetbox.set_offset(loc_in_canvas)
17361736

17371737
def get_loc_in_canvas(self):
1738-
17391738
offsetbox = self.offsetbox
17401739
renderer = offsetbox.figure._cachedRenderer
17411740
w, h, xd, yd = offsetbox.get_extent(renderer)
17421741
ox, oy = offsetbox._offset
17431742
loc_in_canvas = (ox - xd, oy - yd)
1744-
17451743
return loc_in_canvas
17461744

17471745

0 commit comments

Comments
 (0)
0