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

Skip to content

Commit 3c5ef6b

Browse files
authored
Merge pull request #12338 from meeseeksmachine/auto-backport-of-pr-12268-on-v3.0.x
Backport PR #12268 on branch v3.0.x (FIX: remove unnecessary `self` in `super_`-calls, fixes #12265)
2 parents 70e7820 + f0913c4 commit 3c5ef6b

File tree

3 files changed

+38
-4
lines changed

3 files changed

+38
-4
lines changed

lib/mpl_toolkits/axes_grid1/parasite_axes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,14 @@ def _pcolor(self, super_pcolor, *XYC, **kwargs):
106106
X, Y, C = XYC
107107

108108
if "transform" in kwargs:
109-
mesh = super_pcolor(self, X, Y, C, **kwargs)
109+
mesh = super_pcolor(X, Y, C, **kwargs)
110110
else:
111111
orig_shape = X.shape
112112
xyt = np.column_stack([X.flat, Y.flat])
113113
wxy = self.transAux.transform(xyt)
114114
gx = wxy[:, 0].reshape(orig_shape)
115115
gy = wxy[:, 1].reshape(orig_shape)
116-
mesh = super_pcolor(self, gx, gy, C, **kwargs)
116+
mesh = super_pcolor(gx, gy, C, **kwargs)
117117
mesh.set_transform(self._parent_axes.transData)
118118

119119
return mesh
@@ -140,14 +140,14 @@ def _contour(self, super_contour, *XYCL, **kwargs):
140140
CL = XYCL[2:]
141141

142142
if "transform" in kwargs:
143-
cont = super_contour(self, X, Y, *CL, **kwargs)
143+
cont = super_contour(X, Y, *CL, **kwargs)
144144
else:
145145
orig_shape = X.shape
146146
xyt = np.column_stack([X.flat, Y.flat])
147147
wxy = self.transAux.transform(xyt)
148148
gx = wxy[:, 0].reshape(orig_shape)
149149
gy = wxy[:, 1].reshape(orig_shape)
150-
cont = super_contour(self, gx, gy, *CL, **kwargs)
150+
cont = super_contour(gx, gy, *CL, **kwargs)
151151
for c in cont.collections:
152152
c.set_transform(self._parent_axes.transData)
153153

lib/mpl_toolkits/tests/test_axisartist_axislines.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import numpy as np
22
import matplotlib.pyplot as plt
33
from matplotlib.testing.decorators import image_comparison
4+
from matplotlib.transforms import IdentityTransform
45

56
from mpl_toolkits.axisartist.axislines import SubplotZero, Subplot
7+
from mpl_toolkits.axisartist import SubplotHost, ParasiteAxesAuxTrans
68

79
from mpl_toolkits.axisartist import Axes
810

@@ -53,3 +55,35 @@ def test_Axes():
5355
ax.set_xscale('log')
5456

5557
plt.show()
58+
59+
60+
@image_comparison(baseline_images=['ParasiteAxesAuxTrans_meshplot'],
61+
extensions=['png'], remove_text=True, style='default',
62+
tol=0.075)
63+
def test_ParasiteAxesAuxTrans():
64+
65+
data = np.ones((6, 6))
66+
data[2, 2] = 2
67+
data[0, :] = 0
68+
data[-2, :] = 0
69+
data[:, 0] = 0
70+
data[:, -2] = 0
71+
x = np.arange(6)
72+
y = np.arange(6)
73+
xx, yy = np.meshgrid(x, y)
74+
75+
funcnames = ['pcolor', 'pcolormesh', 'contourf']
76+
77+
fig = plt.figure()
78+
for i, name in enumerate(funcnames):
79+
80+
ax1 = SubplotHost(fig, 1, 3, i+1)
81+
fig.add_subplot(ax1)
82+
83+
ax2 = ParasiteAxesAuxTrans(ax1, IdentityTransform())
84+
ax1.parasites.append(ax2)
85+
getattr(ax2, name)(xx, yy, data)
86+
ax1.set_xlim((0, 5))
87+
ax1.set_ylim((0, 5))
88+
89+
ax2.contour(xx, yy, data, colors='k')

0 commit comments

Comments
 (0)