diff --git a/lib/mpl_toolkits/axes_grid1/parasite_axes.py b/lib/mpl_toolkits/axes_grid1/parasite_axes.py index 512c2016d9a1..d003e5c40253 100644 --- a/lib/mpl_toolkits/axes_grid1/parasite_axes.py +++ b/lib/mpl_toolkits/axes_grid1/parasite_axes.py @@ -106,14 +106,14 @@ def _pcolor(self, super_pcolor, *XYC, **kwargs): X, Y, C = XYC if "transform" in kwargs: - mesh = super_pcolor(self, X, Y, C, **kwargs) + mesh = super_pcolor(X, Y, C, **kwargs) else: orig_shape = X.shape xyt = np.column_stack([X.flat, Y.flat]) wxy = self.transAux.transform(xyt) gx = wxy[:, 0].reshape(orig_shape) gy = wxy[:, 1].reshape(orig_shape) - mesh = super_pcolor(self, gx, gy, C, **kwargs) + mesh = super_pcolor(gx, gy, C, **kwargs) mesh.set_transform(self._parent_axes.transData) return mesh @@ -140,14 +140,14 @@ def _contour(self, super_contour, *XYCL, **kwargs): CL = XYCL[2:] if "transform" in kwargs: - cont = super_contour(self, X, Y, *CL, **kwargs) + cont = super_contour(X, Y, *CL, **kwargs) else: orig_shape = X.shape xyt = np.column_stack([X.flat, Y.flat]) wxy = self.transAux.transform(xyt) gx = wxy[:, 0].reshape(orig_shape) gy = wxy[:, 1].reshape(orig_shape) - cont = super_contour(self, gx, gy, *CL, **kwargs) + cont = super_contour(gx, gy, *CL, **kwargs) for c in cont.collections: c.set_transform(self._parent_axes.transData) diff --git a/lib/mpl_toolkits/tests/baseline_images/test_axisartist_axislines/ParasiteAxesAuxTrans_meshplot.png b/lib/mpl_toolkits/tests/baseline_images/test_axisartist_axislines/ParasiteAxesAuxTrans_meshplot.png new file mode 100644 index 000000000000..e8116fe1228f Binary files /dev/null and b/lib/mpl_toolkits/tests/baseline_images/test_axisartist_axislines/ParasiteAxesAuxTrans_meshplot.png differ diff --git a/lib/mpl_toolkits/tests/test_axisartist_axislines.py b/lib/mpl_toolkits/tests/test_axisartist_axislines.py index 4bf67b4b0df7..6fde0c055dd5 100644 --- a/lib/mpl_toolkits/tests/test_axisartist_axislines.py +++ b/lib/mpl_toolkits/tests/test_axisartist_axislines.py @@ -1,8 +1,10 @@ import numpy as np import matplotlib.pyplot as plt from matplotlib.testing.decorators import image_comparison +from matplotlib.transforms import IdentityTransform from mpl_toolkits.axisartist.axislines import SubplotZero, Subplot +from mpl_toolkits.axisartist import SubplotHost, ParasiteAxesAuxTrans from mpl_toolkits.axisartist import Axes @@ -53,3 +55,35 @@ def test_Axes(): ax.set_xscale('log') plt.show() + + +@image_comparison(baseline_images=['ParasiteAxesAuxTrans_meshplot'], + extensions=['png'], remove_text=True, style='default', + tol=0.075) +def test_ParasiteAxesAuxTrans(): + + data = np.ones((6, 6)) + data[2, 2] = 2 + data[0, :] = 0 + data[-2, :] = 0 + data[:, 0] = 0 + data[:, -2] = 0 + x = np.arange(6) + y = np.arange(6) + xx, yy = np.meshgrid(x, y) + + funcnames = ['pcolor', 'pcolormesh', 'contourf'] + + fig = plt.figure() + for i, name in enumerate(funcnames): + + ax1 = SubplotHost(fig, 1, 3, i+1) + fig.add_subplot(ax1) + + ax2 = ParasiteAxesAuxTrans(ax1, IdentityTransform()) + ax1.parasites.append(ax2) + getattr(ax2, name)(xx, yy, data) + ax1.set_xlim((0, 5)) + ax1.set_ylim((0, 5)) + + ax2.contour(xx, yy, data, colors='k')