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

Incompatible with matplotlib 3 #1126

Closed
djhoese opened this issue Sep 25, 2018 · 6 comments
Closed

Incompatible with matplotlib 3 #1126

djhoese opened this issue Sep 25, 2018 · 6 comments
Assignees
Milestone

Comments

@djhoese
Copy link

djhoese commented Sep 25, 2018

Description

It seems some small changes in matplotlib 3.x are causing exceptions in cartopy. The commit in matplotlib that broke things in cartopy is:

matplotlib/matplotlib@86fe16b#diff-43183989add1c60a82728118bd9efe98R2714

The issue is that the img data in imshow is no longer passed as a positional argument but rather as the X keyword argument.

Code to reproduce

In [1]: from cartopy import crs

In [2]: import matplotlib.pyplot as plt

In [3]: import numpy as np

In [4]: ax = plt.axes(projection=crs.PlateCarree())

In [5]: plt.imshow(np.zeros((100, 100)))
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-b314fa645876> in <module>()
----> 1 plt.imshow(np.zeros((100, 100)))

~/anaconda/envs/polar2grid_py36/lib/python3.6/site-packages/matplotlib/pyplot.py in imshow(X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, origin, extent, shape, filternorm, filterrad, imlim, resample, url, data, **kwargs)
   2651         vmax=vmax, origin=origin, extent=extent, shape=shape,
   2652         filternorm=filternorm, filterrad=filterrad, imlim=imlim,
-> 2653         resample=resample, url=url, data=data, **kwargs)
   2654     sci(__ret)
   2655     return __ret

TypeError: imshow() missing 1 required positional argument: 'img'

Traceback

  File "/Users/davidh/anaconda/envs/polar2grid_py36/lib/python3.6/site-packages/matplotlib/pyplot.py", line 2653, in imshow
    resample=resample, url=url, data=data, **kwargs)
TypeError: imshow() missing 1 required positional argument: 'img'
Full environment definition

Operating system

Cartopy version

conda list

pip list

@djhoese
Copy link
Author

djhoese commented Sep 25, 2018

NOTE: This is only a problem if you use the pyplot interface.

@djhoese
Copy link
Author

djhoese commented Sep 25, 2018

CC'ing @anntzer and @jklymak as the committer and merger of the matplotlib change that affected this. To the two of you: is there a way to not pass X by keyword but only by position to the Axes object's imshow method?

@jklymak
Copy link
Contributor

jklymak commented Sep 25, 2018

I don't think I had anything to do w/ that PR 😉

@djhoese
Copy link
Author

djhoese commented Sep 25, 2018

Sorry @jklymak. You're right. I looked at the new PRs that were merged after the associated commit in the commit history. I can't find a PR for this commit. Maybe it was done with a direct push?

@djhoese
Copy link
Author

djhoese commented Sep 25, 2018

Found it: matplotlib/matplotlib#10918
Looks like @anntzer merged it themselves. Now CC'ing @QuLogic who also found this bug.

@dopplershift
Copy link
Contributor

I think this is fixed by matplotlib 3.0.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants