Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ParasiteAxesAuxTrans pcolor/pcolormesh and contour/contourf broken #12265

Closed
kmuehlbauer opened this issue Sep 25, 2018 · 3 comments
Closed

ParasiteAxesAuxTrans pcolor/pcolormesh and contour/contourf broken #12265

kmuehlbauer opened this issue Sep 25, 2018 · 3 comments
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. topic: mpl_toolkit
Milestone

Comments

@kmuehlbauer
Copy link
Contributor

kmuehlbauer commented Sep 25, 2018

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.

@kmuehlbauer
Copy link
Contributor Author

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.

@ImportanceOfBeingErnest
Copy link
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

@anntzer
Copy link
Contributor

anntzer commented Sep 25, 2018

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.

@anntzer anntzer added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Sep 25, 2018
@anntzer anntzer added this to the v3.0.x milestone Sep 25, 2018
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this issue Sep 29, 2018
QuLogic added a commit that referenced this issue Sep 29, 2018
FIX: remove unnecessary `self` in `super_`-calls, fixes #12265
dstansby added a commit that referenced this issue Sep 29, 2018
…268-on-v3.0.x

Backport PR #12268 on branch v3.0.x (FIX: remove unnecessary `self` in `super_`-calls, fixes #12265)
kmuehlbauer added a commit to wradlib/wradlib-notebooks that referenced this issue Oct 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. topic: mpl_toolkit
Projects
None yet
Development

No branches or pull requests

3 participants