8000 Merge pull request #26020 from anntzer/agam · matplotlib/matplotlib@3054ff4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3054ff4

Browse files
authored
Merge pull request #26020 from anntzer/agam
Let AxesGrid support Axes subclasses that don't override axis().
2 parents 7d6d71a + 3798f38 commit 3054ff4

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

lib/mpl_toolkits/axes_grid1/axes_grid.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
from numbers import Number
22
import functools
3+
from types import MethodType
34

45
import numpy as np
56

67
from matplotlib import _api, cbook
78
from matplotlib.gridspec import SubplotSpec
89

910
from .axes_divider import Size, SubplotDivider, Divider
10-
from .mpl_axes import Axes
11+
from .mpl_axes import Axes, SimpleAxisArtist
1112

1213

1314
def _tick_only(ax, bottom_on, left_on):
1415
bottom_off = not bottom_on
1516
left_off = not left_on
16-
ax.axis["bottom"].toggle(ticklabels=bottom_off, label=bottom_off)
17-
ax.axis["left"].toggle(ticklabels=left_off, label=left_off)
17+
if isinstance(ax.axis, MethodType):
18+
bottom = SimpleAxisArtist(ax.xaxis, 1, ax.spines["bottom"])
19+
left = SimpleAxisArtist(ax.yaxis, 1, ax.spines["left"])
20+
else:
21+
bottom = ax.axis["bottom"]
22+
left = ax.axis["left"]
23+
bottom.toggle(ticklabels=bottom_off, label=bottom_off)
24+
left.toggle(ticklabels=left_off, label=left_off)
1825

1926

2027
class CbarAxesBase:

lib/mpl_toolkits/axes_grid1/tests/test_axes_grid1.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,3 +767,7 @@ def test_anchored_locator_base_call():
767767
axins.set(xticks=[], yticks=[])
768768

769769
axins.imshow(Z, extent=extent, origin="lower")
770+
771+
772+
def test_grid_with_axes_class_not_overriding_axis():
773+
Grid(plt.figure(), 111, (2, 2), axes_class=mpl.axes.Axes)

0 commit comments

Comments
 (0)
0