home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 291103680

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
291103680 MDU6SXNzdWUyOTExMDM2ODA= 1852 bug: 2D pcolormesh plots are wrong when coordinate is not ascending order 1386642 closed 0     9 2018-01-24T07:01:07Z 2018-02-18T19:06:31Z 2018-02-18T19:06:31Z CONTRIBUTOR      

Code Sample, a copy-pastable example if possible

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

x = np.arange(10) y = np.arange(20)

np.random.shuffle(x)

x = xr.DataArray(x, dims=['x'], coords={'x': x}) y = xr.DataArray(y, dims=['y'], coords={'y': y})

z = x + y z_sorted = z.isel(x=np.argsort(x.values))

make plot

fig, axs= plt.subplots(1, 2, figsize=(6,3)) z_sorted.plot(ax=axs[0]) axs[0].set_title("X is sorted")

z.plot(ax=axs[1]) axs[1].set_title("X is not unsorted") plt.tight_layout() ```

Problem description

Sometime the coordinates in an xarray dataset are not always sorted in ascending order. I recently had an issue where the time coordinate of a 2D datasets was scrambled, so calling x.plot gave very strange results. In my opinion, x.plot should probably sort the data along the coordinates, or at least provide a warning if the coordinates are unsorted.

Expected Output

Here is the image generated by the snippet above:

The left and right panels should be the same.

Paste the output here xr.show_versions() here

INSTALLED VERSIONS ------------------ commit: None python: 3.6.2.final.0 python-bits: 64 OS: Darwin OS-release: 16.0.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8 xarray: 0.10.0+dev50.ga988dc2 pandas: 0.20.3 numpy: 1.13.1 scipy: 0.19.1 netCDF4: 1.3.1 h5netcdf: 0.5.0 Nio: None zarr: None bottleneck: 1.2.1 cyordereddict: None dask: 0.15.2 distributed: 1.18.3 matplotlib: 2.0.2 cartopy: None seaborn: 0.8.0 setuptools: 36.5.0.post20170921 pip: 9.0.1 conda: 4.3.29 pytest: 3.2.1 IPython: 6.1.0 sphinx: 1.6.3
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/1852/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
  • 9 rows from issue in issue_comments
Powered by Datasette · Queries took 0.545ms · About: xarray-datasette