Skip to content

ParasiteAxesAuxTrans pcolor/pcolormesh and contour/contourf broken #12265

Closed

Description

@kmuehlbauer

Bug report

Bug summary

Calling pcolormesh/pcolor or contour/contourf from a parasite axes created with ParasiteAxesAuxTrans breaks. In the call to create the mesh using super_pcolor (or super_contour) an additional self is added to the *args:

mesh = super_pcolor(self, gx, gy, C, **kwargs)

This breaks subsequent pcolor/pcolormesh/pcontour/pcontourf processing.

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.axisartist import SubplotHost, ParasiteAxesAuxTrans
from matplotlib.projections import PolarAxes
from matplotlib.transforms import Affine2D

fig = plt.figure(1, figsize=(7, 4))
ax1 = SubplotHost(fig, 1, 1, 1)
fig.add_subplot(ax1)
tr = Affine2D().scale(np.pi/180., 1.) + PolarAxes.PolarTransform()
ax2 = ParasiteAxesAuxTrans(ax1, tr, "equal")
ax1.parasites.append(ax2)
data = np.random.random((360,10))
x = np.arange(data.shape[0])
y = np.arange(data.shape[1])
xx, yy = np.meshgrid(x, y)
ax2.pcolormesh(xx, yy, data.T)
ax1.set_xlim(-10, 10)
ax1.set_ylim(-10, 10)
plt.show()

Actual outcome

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-1-3448b36e4131> in <module>()
     15 y = np.arange(data.shape[1])
     16 xx, yy = np.meshgrid(x, y)
---> 17 ax2.pcolormesh(xx, yy, data.T)
     18 ax1.set_xlim(-10, 10)
     19 ax1.set_ylim(-10, 10)

/home/kai/miniconda3/envs/wradlib/lib/python3.6/site-packages/mpl_toolkits/axes_grid1/parasite_axes.py in pcolormesh(self, *XYC, **kwargs)
    120 
    121     def pcolormesh(self, *XYC, **kwargs):
--> 122         return self._pcolor(super().pcolormesh, *XYC, **kwargs)
    123 
    124     def pcolor(self, *XYC, **kwargs):

/home/kai/miniconda3/envs/wradlib/lib/python3.6/site-packages/mpl_toolkits/axes_grid1/parasite_axes.py in _pcolor(self, super_pcolor, *XYC, **kwargs)
    114             gx = wxy[:, 0].reshape(orig_shape)
    115             gy = wxy[:, 1].reshape(orig_shape)
--> 116             mesh = super_pcolor(self, gx, gy, C, **kwargs)
    117             mesh.set_transform(self._parent_axes.transData)
    118 

/home/kai/miniconda3/envs/wradlib/lib/python3.6/site-packages/matplotlib/__init__.py in inner(ax, data, *args, **kwargs)
   1783                         "the Matplotlib list!)" % (label_namer, func.__name__),
   1784                         RuntimeWarning, stacklevel=2)
-> 1785             return func(ax, *args, **kwargs)
   1786 
   1787         inner.__doc__ = _add_data_doc(inner.__doc__,

/home/kai/miniconda3/envs/wradlib/lib/python3.6/site-packages/matplotlib/axes/_axes.py in pcolormesh(self, alpha, norm, cmap, vmin, vmax, shading, antialiased, *args, **kwargs)
   5957         allmatch = (shading == 'gouraud')
   5958 
-> 5959         X, Y, C = self._pcolorargs('pcolormesh', *args, allmatch=allmatch)
   5960         Ny, Nx = X.shape
   5961         X = X.ravel()

/home/kai/miniconda3/envs/wradlib/lib/python3.6/site-packages/matplotlib/axes/_axes.py in _pcolorargs(funcname, allmatch, *args)
   5527         else:
   5528             raise TypeError(
-> 5529                 'Illegal arguments to %s; see help(%s)' % (funcname, funcname))
   5530 
   5531         Nx = X.shape[-1]

TypeError: Illegal arguments to pcolormesh; see help(pcolormesh)

Expected outcome

parasite_axes

Works before PR #11678.

Matplotlib version

  • Operating system: Linux
  • Matplotlib version: 3.0.0
  • Matplotlib backend (print(matplotlib.get_backend())): Qt5Agg
  • Python version: 3.6.6
  • Jupyter version (if applicable):
  • Other libraries:

Running conda environment using conda-forge channel.

Activity

  1. added a commit that references this issue on Sep 25, 2018
    703219a
  2. kmuehlbauer commented on Sep 25, 2018

    @kmuehlbauer
    ContributorAuthor

    Since I do not have that much insight into the matplotlib machinery, I can't tell, if this commit is sufficient to fix this. At least it works as expected on my machine. Happy to create a PR.

  3. ImportanceOfBeingErnest commented on Sep 25, 2018

    @ImportanceOfBeingErnest
    Member

    PRs are welcome. Especially if it could also add a test for this.

    Maybe @anntzer can comment on why he put self in there in the first place in #11678

  4. anntzer commented on Sep 25, 2018

    @anntzer
    Contributor

    Because I was hoping that errors like this would be caught by CI? :p
    Anyways it's clearly a mistake on my part, the fix looks good, thanks.

  5. added
    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
    on Sep 25, 2018
  6. added this to the v3.0.x milestone on Sep 25, 2018
  7. added a commit that references this issue on Sep 27, 2018
    f11a881
  8. added a commit that references this issue on Sep 29, 2018
    f0913c4
  9. added a commit that references this issue on Sep 29, 2018
    c15a2b8
  10. added a commit that references this issue on Sep 29, 2018
    3c5ef6b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.topic: mpl_toolkit

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions