8000 Merge pull request #14459 from anntzer/draggablebase · matplotlib/matplotlib@e0555bf · GitHub
[go: up one dir, main page]

Skip to content

Commit e0555bf

Browse files
authored
Merge pull request #14459 from anntzer/draggablebase
Cleanup docstring of DraggableBase.
2 parents dfaa410 + 63c44b2 commit e0555bf

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
@@ -1592,35 +1592,35 @@ def draw(self, renderer):
15921592

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

16261626
def __init__(self, ref_artist, use_blit=False):
@@ -1690,7 +1690,7 @@ def _check_still_parented(self):
16901690
return True
16911691

16921692
def disconnect(self):
1693-
"""disconnect the callbacks"""
1693+
"""Disconnect the callbacks."""
16941694
for cid in self.cids:
16951695
self.canvas.mpl_disconnect(cid)
16961696
try:
@@ -1731,13 +1731,11 @@ def update_offset(self, dx, dy):
17311731
self.offsetbox.set_offset(loc_in_canvas)
17321732

17331733
def get_loc_in_canvas(self):
1734-
17351734
offsetbox = self.offsetbox
17361735
renderer = offsetbox.figure._cachedRenderer
17371736
w, h, xd, yd = offsetbox.get_extent(renderer)
17381737
ox, oy = offsetbox._offset
17391738
loc_in_canvas = (ox - xd, oy - yd)
1740-
17411739
return loc_in_canvas
17421740

17431741

0 commit comments

Comments
 (0)
0