8000 Merge pull request #29424 from timhoffm/mnt-axis-map · matplotlib/matplotlib@419b661 · GitHub
[go: up one dir, main page]

Skip to content

Commit 419b661

Browse files
authored
Merge pull request #29424 from timhoffm/mnt-axis-map
MNT: Turn Axes._axis_map into a static dict instead of a property
2 parents c3567c3 + 1de7880 commit 419b661

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -565,12 +565,6 @@ class _AxesBase(martist.Artist):
565565
dataLim: mtransforms.Bbox
566566
"""The bounding `.Bbox` enclosing all data displayed in the Axes."""
567567

568-
@property
569-
def _axis_map(self):
570-
"""A mapping of axis names, e.g. 'x', to `Axis` instances."""
571-
return {name: getattr(self, f"{name}axis")
572-
for name in self._axis_names}
573-
574568
def __str__(self):
575569
return "{0}({1[0]:g},{1[1]:g};{1[2]:g}x{1[3]:g})".format(
576570
type(self).__name__, self._position.bounds)
@@ -685,6 +679,9 @@ def __init__(self, fig,
685679

686680
# this call may differ for non-sep axes, e.g., polar
687681
self._init_axis()
682+
self._axis_map = {
683+
name: getattr(self, f"{name}axis") for name in self._axis_names
684+
} # A mapping of axis names, e.g. 'x', to `Axis` instances.
688685
self._facecolor = mpl._val_or_rc(facecolor, 'axes.facecolor')
689686
self._frameon = frameon
690687
self.set_axisbelow(mpl.rcParams['axes.axisbelow'])

lib/matplotlib/axes/_base.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ from collections.abc import Callable, Iterable, Iterator, Sequence
55
from matplotlib import cbook
66
from matplotlib.artist import Artist
77
from matplotlib.axes import Axes
8-
from matplotlib.axis import XAxis, YAxis, Tick
8+
from matplotlib.axis import Axis, XAxis, YAxis, Tick
99
from matplotlib.backend_bases import RendererBase, MouseButton, MouseEvent
1010
from matplotlib.cbook import CallbackRegistry
1111
from matplotlib.container import Container
@@ -62,6 +62,7 @@ class _AxesBase(martist.Artist):
6262
child_axes: list[_AxesBase]
6363
legend_: Legend | None
6464
title: Text
65+
_axis_map: dict[str, Axis]
6566
_projection_init: Any
6667

6768
def __init__(

0 commit comments

Comments
 (0)
0