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

Skip to content

Commit 9e5fe16

Browse files
committed
Support standard Axes in RGBAxes.
The same fix as the one recently applied to AxesGrid.
1 parent 3044bde commit 9e5fe16

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

lib/mpl_toolkits/axes_grid1/axes_rgb.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
from types import MethodType
2+
13
import numpy as np
24

35
from .axes_divider import make_axes_locatable, Size
4-
from .mpl_axes import Axes
6+
from .mpl_axes import Axes, SimpleAxisArtist
57

68

79
def make_rgb_axes(ax, pad=0.01, axes_class=None, **kwargs):
@@ -108,8 +110,17 @@ def __init__(self, *args, pad=0, **kwargs):
108110
ax, pad=pad, axes_class=axes_class, **kwargs)
109111
# Set the line color and ticks for the axes.
110112
for ax1 in [self.RGB, self.R, self.G, self.B]:
111-
ax1.axis[:].line.set_color("w")
112-
ax1.axis[:].major_ticks.set_markeredgecolor("w")
113+
if isinstance(ax1.axis, MethodType):
114+
ad = Axes.AxisDict(self)
115+
ad.update(
116+
bottom=SimpleAxisArtist(ax1.xaxis, 1, ax1.spines["bottom"]),
117+
top=SimpleAxisArtist(ax1.xaxis, 2, ax1.spines["top"]),
118+
left=SimpleAxisArtist(ax1.yaxis, 1, ax1.spines["left"]),
119+
right=SimpleAxisArtist(ax1.yaxis, 2, ax1.spines["right"]))
120+
else:
121+
ad = ax1.axis
122+
ad[:].line.set_color("w")
123+
ad[:].major_ticks.set_markeredgecolor("w")
113124

114125
def imshow_rgb(self, r, g, b, **kwargs):
115126
"""

lib/mpl_toolkits/axes_grid1/tests/test_axes_grid1.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,3 +781,4 @@ def test_anchored_locator_base_call():
781781

782782
def test_grid_with_axes_class_not_overriding_axis():
783783
Grid(plt.figure(), 111, (2, 2), axes_class=mpl.axes.Axes)
784+
RGBAxes(plt.figure(), 111, axes_class=mpl.axes.Axes)

0 commit comments

Comments
 (0)