8000 Cleanup axes/_base.py. by anntzer · Pull Request #12855 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Cleanup axes/_base.py. #12855

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
Nov 23, 2018
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion lib/matplotlib/artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ def hitlist(self, event):
return L

def get_children(self):
r"""Return a list of the child `.Artist`\s this `.Artist` contains."""
r"""Return a list of the child `.Artist`\s of this `.Artist`."""
return []

def contains(self, mouseevent):
Expand Down
64 changes: 20 additions & 44 deletions lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4208,60 +4208,36 @@ def format_deltas(key, dx, dy):
self.set_ylim(points[:, 1])

def get_children(self):
"""return a list of child artists"""
children = []
children.extend(self.collections)
children.extend(self.patches)
children.extend(self.lines)
children.extend(self.texts)
children.extend(self.artists)
children.extend(self.spines.values())
children.append(self.xaxis)
children.append(self.yaxis)
children.append(self.title)
children.append(self._left_title)
children.append(self._right_title)
children.extend(self.tables)
children.extend(self.images)
children.extend(self.child_axes)

if self.legend_ is not None:
children.append(self.legend_)
children.append(self.patch)

return children
# docstring inherited.
return [
*self.collections,
*self.patches,
*self.lines,
*self.texts,
*self.artists,
*self.spines.values(),
*self._get_axis_list(),
self.title, self._left_title, self._right_title,
*self.tables,
*self.images,
*self.child_axes,
*([self.legend_] if self.legend_ is not None else []),
self.patch,
]

def contains(self, mouseevent):
"""
Test whether the mouse event occurred in the axes.

Returns *True* / *False*, {}
"""
# docstring inherited.
if callable(self._contains):
return self._contains(self, mouseevent)
return self.patch.contains(mouseevent)

def contains_point(self, point):
"""
Returns *True* if the point (tuple of x,y) is inside the axes
(the area defined by the its patch). A pixel coordinate is
required.

Returns whether *point* (pair of pixel coordinates) is inside the axes
patch.
"""
return self.patch.contains_point(point, radius=1.0)

def pick(self, *args):
"""Trigger pick event

Call signature::

pick(mouseevent)

each child artist will fire a pick event if mouseevent is over
the artist and the artist has picker set
"""
martist.Artist.pick(self, args[0])

def get_default_bbox_extra_artists(self):
"""
Return a default list of artists that are used for the bounding box
Expand All @@ -4285,7 +4261,7 @@ def get_default_bbox_extra_artists(self):
if (artist.get_visible() and artist.get_in_layout())]

def get_tightbbox(self, renderer, call_axes_locator=True,
bbox_extra_artists=None):
bbox_extra_artists=None):
"""
Return the tight bounding box of the axes, including axis and their
decorators (xlabel, title, etc).
Expand Down
3 changes: 0 additions & 3 deletions lib/mpl_toolkits/mplot3d/axes3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,6 @@ def _init_axis(self):
for ax in self.xaxis, self.yaxis, self.zaxis:
ax.init3d()

def get_children(self):
return [self.zaxis] + super().get_children()

def _get_axis_list(self):
return super()._get_axis_list() + (self.zaxis, )

Expand Down
0