Thanks to visit codestin.com
Credit goes to github.com

Skip to content

DOC: More cleanup axes -> Axes #22337

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
Jan 28, 2022
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
11 changes: 5 additions & 6 deletions lib/matplotlib/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1161,11 +1161,11 @@ def _blit_draw(self, artists):
# Handles blitted drawing, which renders only the artists given instead
# of the entire figure.
updated_ax = {a.axes for a in artists}
# Enumerate artists to cache axes' backgrounds. We do not draw
# Enumerate artists to cache Axes backgrounds. We do not draw
# artists yet to not cache foreground from plots with shared axes
for ax in updated_ax:
# If we haven't cached the background for the current view of this
# axes object, do so now. This might not always be reliable, but
# Axes object, do so now. This might not always be reliable, but
# it's an attempt to automate the process.
cur_view = ax._get_view()
view, bg = self._blit_cache.get(ax, (object(), None))
Expand All @@ -1175,12 +1175,12 @@ def _blit_draw(self, artists):
# Make a separate pass to draw foreground.
for a in artists:
a.axes.draw_artist(a)
# After rendering all the needed artists, blit each axes individually.
# After rendering all the needed artists, blit each Axes individually.
for ax in updated_ax:
ax.figure.canvas.blit(ax.bbox)

def _blit_clear(self, artists):
# Get a list of the axes that need clearing from the artists that
# Get a list of the Axes that need clearing from the artists that
# have been drawn. Grab the appropriate saved background from the
# cache and restore.
axes = {a.axes for a in artists}
Expand All @@ -1195,8 +1195,7 @@ def _blit_clear(self, artists):
self._blit_cache.pop(ax)

def _setup_blit(self):
# Setting up the blit requires: a cache of the background for the
# axes
# Setting up the blit requires: a cache of the background for the Axes
self._blit_cache = dict()
self._drawn_artists = []
self._resize_id = self._fig.canvas.mpl_connect('resize_event',
Expand Down
12 changes: 5 additions & 7 deletions lib/matplotlib/artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,8 @@ def remove(self):
if hasattr(self, 'axes') and self.axes:
# remove from the mouse hit list
self.axes._mouseover_set.discard(self)
# mark the axes as stale
self.axes.stale = True
# decouple the artist from the axes
self.axes = None
self.axes = None # decouple the artist from the Axes
_ax_flag = True

if self.figure:
Expand Down Expand Up @@ -511,14 +509,14 @@ def pick(self, mouseevent):

# Pick children
for a in self.get_children():
# make sure the event happened in the same axes
# make sure the event happened in the same Axes
ax = getattr(a, 'axes', None)
if (mouseevent.inaxes is None or ax is None
or mouseevent.inaxes == ax):
# we need to check if mouseevent.inaxes is None
# because some objects associated with an Axes (e.g., a
# tick label) can be outside the bounding box of the
# axes and inaxes will be None
# Axes and inaxes will be None
# also check that ax is None so that it traverse objects
# which do no have an axes property but children might
a.pick(mouseevent)
Expand Down Expand Up @@ -829,7 +827,7 @@ def get_in_layout(self):

def _fully_clipped_to_axes(self):
"""
Return a boolean flag, ``True`` if the artist is clipped to the axes
Return a boolean flag, ``True`` if the artist is clipped to the Axes
and can thus be skipped in layout calculations. Requires `get_clip_on`
is True, one of `clip_box` or `clip_path` is set, ``clip_box.extents``
is equivalent to ``ax.bbox.extents`` (if set), and ``clip_path._patch``
Expand Down Expand Up @@ -877,7 +875,7 @@ def set_clip_on(self, b):
"""
Set whether the artist uses clipping.

When False artists will be visible outside of the axes which
When False artists will be visible outside of the Axes which
can lead to unexpected results.

Parameters
Expand Down
34 changes: 17 additions & 17 deletions lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class _TransformedBoundsLocator:
Axes locator for `.Axes.inset_axes` and similarly positioned Axes.

The locator is a callable object used in `.Axes.set_aspect` to compute the
axes location depending on the renderer.
Axes location depending on the renderer.
"""

def __init__(self, bounds, transform):
Expand Down Expand Up @@ -1117,7 +1117,7 @@ def _gen_axes_patch(self):
The patch used to draw the background of the Axes. It is also used
as the clipping path for any data elements on the Axes.

In the standard axes, this is a rectangle, but in other projections
In the standard Axes, this is a rectangle, but in other projections
it may not be.

Notes
Expand Down Expand Up @@ -1149,7 +1149,7 @@ def sharex(self, other):
Share the x-axis with *other*.

This is equivalent to passing ``sharex=other`` when constructing the
axes, and cannot be used if the x-axis is already being shared with
Axes, and cannot be used if the x-axis is already being shared with
another Axes.
"""
_api.check_isinstance(_AxesBase, other=other)
Expand All @@ -1168,7 +1168,7 @@ def sharey(self, other):
Share the y-axis with *other*.

This is equivalent to passing ``sharey=other`` when constructing the
axes, and cannot be used if the y-axis is already being shared with
Axes, and cannot be used if the y-axis is already being shared with
another Axes.
"""
_api.check_isinstance(_AxesBase, other=other)
Expand Down Expand Up @@ -2413,7 +2413,7 @@ def add_table(self, tab):

def add_container(self, container):
"""
Add a `.Container` to the axes' containers; return the container.
Add a `.Container` to the Axes' containers; return the container.
"""
label = container.get_label()
if not label:
Expand Down Expand Up @@ -2499,8 +2499,8 @@ def _process_unit_info(self, datasets=None, kwargs=None, *, convert=True):
(which gets passed through).
kwargs : dict
Other parameters from which unit info (i.e., the *xunits*,
*yunits*, *zunits* (for 3D axes), *runits* and *thetaunits* (for
polar axes) entries) is popped, if present. Note that this dict is
*yunits*, *zunits* (for 3D Axes), *runits* and *thetaunits* (for
polar) entries) is popped, if present. Note that this dict is
mutated in-place!
convert : bool, default: True
Whether to return the original datasets or the converted ones.
Expand Down Expand Up @@ -2779,7 +2779,7 @@ def autoscale(self, enable=True, axis='both', tight=None):
True turns autoscaling on, False turns it off.
None leaves the autoscaling state unchanged.
axis : {'both', 'x', 'y'}, default: 'both'
The axis on which to operate. (For 3D axes, *axis* can also be set
The axis on which to operate. (For 3D Axes, *axis* can also be set
to 'z', and 'both' refers to all three axes.)
tight : bool or None, default: None
If True, first set the margins to zero. Then, this argument is
Expand Down Expand Up @@ -2853,7 +2853,7 @@ def autoscale_view(self, tight=None, scalex=True, scaley=True):
if self.use_sticky_edges:
# Only iterate over Axes and artists if needed. The check for
# ``hasattr(ax, "_children")`` is necessary because this can be
# called very early in the Axes init process (e.g., for twin axes)
# called very early in the Axes init process (e.g., for twin Axes)
# when these attributes don't even exist yet, in which case
# `get_children` would raise an AttributeError.
if self._xmargin and scalex and self._autoscaleXon:
Expand Down Expand Up @@ -2953,7 +2953,7 @@ def _get_axis_map(self):
Return a mapping of `Axis` "names" to `Axis` instances.

The `Axis` name is derived from the attribute under which the instance
is stored, so e.g. for polar axes, the theta-axis is still named "x"
is stored, so e.g. for polar Axes, the theta-axis is still named "x"
and the r-axis is still named "y" (for back-compatibility).

In practice, this means that the entries are typically "x" and "y", and
Expand Down Expand Up @@ -3245,7 +3245,7 @@ def grid(self, visible=None, which='major', axis='both', **kwargs):
def ticklabel_format(self, *, axis='both', style='', scilimits=None,
useOffset=None, useLocale=None, useMathText=None):
r"""
Configure the `.ScalarFormatter` used by default for linear axes.
Configure the `.ScalarFormatter` used by default for linear Axes.

If a parameter is not set, the corresponding property of the formatter
is left unchanged.
Expand Down Expand Up @@ -3327,7 +3327,7 @@ def locator_params(self, axis='both', tight=None, **kwargs):
Parameters
----------
axis : {'both', 'x', 'y'}, default: 'both'
The axis on which to operate. (For 3D axes, *axis* can also be
The axis on which to operate. (For 3D Axes, *axis* can also be
set to 'z', and 'both' refers to all three axes.)
tight : bool or None, optional
Parameter passed to `~.Axes.autoscale_view`.
Expand All @@ -3340,7 +3340,7 @@ def locator_params(self, axis='both', tight=None, **kwargs):
``set_params()`` method of the locator. Supported keywords depend
on the type of the locator. See for example
`~.ticker.MaxNLocator.set_params` for the `.ticker.MaxNLocator`
used by default for linear axes.
used by default for linear.

Examples
--------
Expand Down Expand Up @@ -3377,7 +3377,7 @@ def tick_params(self, axis='both', **kwargs):
Other Parameters
----------------
direction : {'in', 'out', 'inout'}
Puts ticks inside the axes, outside the axes, or both.
Puts ticks inside the Axes, outside the Axes, or both.
length : float
Tick length in points.
width : float
Expand Down Expand Up @@ -4538,7 +4538,7 @@ def contains(self, mouseevent):

def contains_point(self, point):
"""
Return whether *point* (pair of pixel coordinates) is inside the axes
Return whether *point* (pair of pixel coordinates) is inside the Axes
patch.
"""
return self.patch.contains_point(point, radius=1.0)
Expand Down Expand Up @@ -4568,7 +4568,7 @@ def get_default_bbox_extra_artists(self):
artists.remove(self._right_title)

# always include types that do not internally implement clipping
# to axes. may have clip_on set to True and clip_box equivalent
# to Axes. may have clip_on set to True and clip_box equivalent
# to ax.bbox but then ignore these properties during draws.
noclip = (_AxesBase, maxis.Axis,
offsetbox.AnnotationBbox, offsetbox.OffsetBox)
Expand All @@ -4578,7 +4578,7 @@ def get_default_bbox_extra_artists(self):
def get_tightbbox(self, renderer, call_axes_locator=True,
bbox_extra_artists=None, *, for_layout_only=False):
"""
Return the tight bounding box of the axes, including axis and their
Return the tight bounding box of the Axes, including axis and their
decorators (xlabel, title, etc).

Artists that have ``artist.set_in_layout(False)`` are not included
Expand Down
22 changes: 11 additions & 11 deletions lib/matplotlib/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def get_tickdir(self):
return self._tickdir

def get_tick_padding(self):
"""Get the length of the tick outside of the axes."""
"""Get the length of the tick outside of the Axes."""
padding = {
'in': 0.0,
'inout': 0.5,
Expand Down Expand Up @@ -1869,7 +1869,7 @@ def _get_tick_boxes_siblings(self, renderer):
grouper = self.figure._align_label_groups[axis_name]
bboxes = []
bboxes2 = []
# If we want to align labels from other axes:
# If we want to align labels from other Axes:
for ax in grouper.get_siblings(self.axes):
axis = getattr(ax, f"{axis_name}axis")
ticks_to_draw = axis._update_ticks()
Expand Down Expand Up @@ -2083,7 +2083,7 @@ def _update_label_position(self, renderer):
spine = self.axes.spines['bottom']
spinebbox = spine.get_window_extent()
except KeyError:
# use axes if spine doesn't exist
# use Axes if spine doesn't exist
spinebbox = self.axes.bbox
bbox = mtransforms.Bbox.union(bboxes + [spinebbox])
bottom = bbox.y0
Expand All @@ -2096,7 +2096,7 @@ def _update_label_position(self, renderer):
spine = self.axes.spines['top']
spinebbox = spine.get_window_extent()
except KeyError:
# use axes if spine doesn't exist
# use Axes if spine doesn't exist
spinebbox = self.axes.bbox
bbox = mtransforms.Bbox.union(bboxes2 + [spinebbox])
top = bbox.y1
Expand Down Expand Up @@ -2132,7 +2132,7 @@ def _update_offset_text_position(self, bboxes, bboxes2):
def get_text_heights(self, renderer):
"""
Return how much space should be reserved for text above and below the
axes, as a pair of floats.
Axes, as a pair of floats.
"""
bbox, bbox2 = self.get_ticklabel_extents(renderer)
# MGDTODO: Need a better way to get the pad
Expand Down Expand Up @@ -2193,7 +2193,7 @@ def set_ticks_position(self, position):

def tick_top(self):
"""
Move ticks and ticklabels (if present) to the top of the axes.
Move ticks and ticklabels (if present) to the top of the Axes.
"""
label = True
if 'label1On' in self._major_tick_kw:
Expand All @@ -2205,7 +2205,7 @@ def tick_top(self):

def tick_bottom(self):
"""
Move ticks and ticklabels (if present) to the bottom of the axes.
Move ticks and ticklabels (if present) to the bottom of the Axes.
"""
label = True
if 'label1On' in self._major_tick_kw:
Expand Down Expand Up @@ -2347,7 +2347,7 @@ def _update_label_position(self, renderer):
spine = self.axes.spines['left']
spinebbox = spine.get_window_extent()
except KeyError:
# use axes if spine doesn't exist
# use Axes if spine doesn't exist
spinebbox = self.axes.bbox
bbox = mtransforms.Bbox.union(bboxes + [spinebbox])
left = bbox.x0
Expand All @@ -2360,7 +2360,7 @@ def _update_label_position(self, renderer):
spine = self.axes.spines['right']
spinebbox = spine.get_window_extent()
except KeyError:
# use axes if spine doesn't exist
# use Axes if spine doesn't exist
spinebbox = self.axes.bbox

bbox = mtransforms.Bbox.union(bboxes2 + [spinebbox])
Expand Down Expand Up @@ -2449,7 +2449,7 @@ def set_ticks_position(self, position):

def tick_right(self):
"""
Move ticks and ticklabels (if present) to the right of the axes.
Move ticks and ticklabels (if present) to the right of the Axes.
"""
label = True
if 'label1On' in self._major_tick_kw:
Expand All @@ -2462,7 +2462,7 @@ def tick_right(self):

def tick_left(self):
"""
Move ticks and ticklabels (if present) to the left of the axes.
Move ticks and ticklabels (if present) to the left of the Axes.
"""
label = True
if 'label1On' in self._major_tick_kw:
Expand Down
Loading