home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 453126577

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
453126577 MDU6SXNzdWU0NTMxMjY1Nzc= 3002 plot.pcolormesh fails with shading='gouraud' 35968931 closed 0     5 2019-06-06T16:27:00Z 2020-11-29T16:28:32Z 2019-06-06T22:26:35Z MEMBER      

xarray.plot.pcolormesh() fails when you pass the matplotlib.pyplot.pcolormesh() keyword argument shading='gouraud' to it.

Code Sample, a copy-pastable example if possible

```python import matplotlib.pyplot as plt import numpy as np import xarray as xr

lon, lat = np.meshgrid(np.linspace(-20, 20, 5), np.linspace(0, 30, 4)) lon += lat/10 lat += lon/10

da = xr.DataArray(np.arange(20).reshape(4, 5), dims=['y', 'x'], coords = {'lat': (('y', 'x'), lat), 'lon': (('y', 'x'), lon)})

da.plot.pcolormesh('lon', 'lat', shading='gouraud') plt.show() ```

Problem description

This gives an error:

Traceback (most recent call last): File "mwe.py", line 17, in <module> da.plot.pcolormesh('lon', 'lat', shading='gouraud') File "/home/tegn500/Documents/Work/Code/xarray/xarray/plot/plot.py", line 721, in plotmethod return newplotfunc(**allargs) File "/home/tegn500/Documents/Work/Code/xarray/xarray/plot/plot.py", line 662, in newplotfunc **kwargs) File "/home/tegn500/Documents/Work/Code/xarray/xarray/plot/plot.py", line 864, in pcolormesh primitive = ax.pcolormesh(x, y, z, **kwargs) File "/home/tegn500/anaconda3/envs/py36/lib/python3.6/site-packages/matplotlib/__init__.py", line 1805, in inner return func(ax, *args, **kwargs) File "/home/tegn500/anaconda3/envs/py36/lib/python3.6/site-packages/matplotlib/axes/_axes.py", line 5971, in pcolormesh X, Y, C = self._pcolorargs('pcolormesh', *args, allmatch=allmatch) File "/home/tegn500/anaconda3/envs/py36/lib/python3.6/site-packages/matplotlib/axes/_axes.py", line 5559, in _pcolorargs C.shape, Nx, Ny, funcname)) TypeError: Dimensions of C (4, 5) are incompatible with X (6) and/or Y (5); see help(pcolormesh)

Expected Output

This should give almost the same image as in the documentation, just with smoother shading:

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/3002/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed 13221727 issue

Links from other tables

  • 0 rows from issues_id in issues_labels
  • 5 rows from issue in issue_comments
Powered by Datasette · Queries took 0.603ms · About: xarray-datasette