8000 Cleanup docstring of DraggableBase. by anntzer · Pull Request #14459 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Cleanup docstring of DraggableBase. #14459

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 23 additions & 25 deletions lib/matplotlib/offsetbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -1592,35 +1592,35 @@ def draw(self, renderer):

class DraggableBase:
"""
helper code for a draggable artist (legend, offsetbox)
The derived class must override following two method.
Helper base class for a draggable artist (legend, offsetbox).

def save_offset(self):
pass
Derived classes must override the following methods::

def update_offset(self, dx, dy):
pass
def save_offset(self):
'''
Called when the object is picked for dragging; should save the
reference position of the artist.
'''

*save_offset* is called when the object is picked for dragging and it
is meant to save reference position of the artist.
def update_offset(self, dx, dy):
'''
Called during the dragging; (*dx*, *dy*) is the pixel offset from
the point where the mouse drag started.
'''

*update_offset* is called during the dragging. dx and dy is the pixel
offset from the point where the mouse drag started.
Optionally, you may override the following methods::

Optionally you may override following two methods.
def artist_picker(self, artist, evt):
'''The picker method that will be used.'''
return self.ref_artist.contains(evt)

def artist_picker(self, artist, evt):
return self.ref_artist.contains(evt)
def finalize_offset(self):
'''Called when the mouse is released.'''

def finalize_offset(self):
pass

*artist_picker* is a picker method that will be
used. *finalize_offset* is called when the mouse is released. In
current implementation of DraggableLegend and DraggableAnnotation,
*update_offset* places the artists simply in display
coordinates. And *finalize_offset* recalculate their position in
the normalized axes coordinate and set a relevant attribute.
In the current implementation of `DraggableLegend` and
`DraggableAnnotation`, `update_offset` places the artists in display
coordinates, and `finalize_offset` recalculates their position in axes
coordinate and set a relevant attribute.
"""

def __init__(self, ref_artist, use_blit=False):
Expand Down Expand Up @@ -1690,7 +1690,7 @@ def _check_still_parented(self):
return True

def disconnect(self):
"""disconnect the callbacks"""
"""Disconnect the callbacks."""
for cid in self.cids:
self.canvas.mpl_disconnect(cid)
try:
Expand Down Expand Up @@ -1731,13 +1731,11 @@ def update_offset(self, dx, dy):
self.offsetbox.set_offset(loc_in_canvas)

def get_loc_in_canvas(self):

offsetbox = self.offsetbox
renderer = offsetbox.figure._cachedRenderer
w, h, xd, yd = offsetbox.get_extent(renderer)
ox, oy = offsetbox._offset
loc_in_canvas = (ox - xd, oy - yd)

return loc_in_canvas


Expand Down
0