home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 292054887

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
292054887 MDU6SXNzdWUyOTIwNTQ4ODc= 1862 Weird looking plots from combined DataArrays 244887 closed 0     5 2018-01-26T22:48:04Z 2019-01-22T22:48:54Z 2019-01-22T22:48:54Z CONTRIBUTOR      

I am trying to figure out how to plot 2 dimensional data from multiple data arrays that share common coordinates. My first guess was to throw the data arrays into a dataset and call a plot method, but it seems that is unsupported (perhaps with good reason). My second idea was to trying to "merge" the data arrays into a single one and then call the plot method. Here is what I get:

```python N = 2**6 x, y = range(N), range(N) n = int(N/4) A, B = np.random.rand(n,n), np.random.rand(n,n)

xrA = xr.DataArray(A, dims=('x','y'), coords={'x':x[:n],'y':y[:n]}) xrB = xr.DataArray(B, dims=('x','y'), coords={'x':x[-n:],'y':y[-n:]})

xrAB = xrA.combine_first(xrB)

dataarrays = [xrA,xrB,xrAB]

fig,axs = plt.subplots(1,3,figsize=(15,4)) for ax,data in zip(axs,dataarrays): data.plot(ax=ax) ```

I was not expecting to see the funny looking artifacts extending from the edges of the region with non nan data. A slightly more elaborate version with three non nan regions shows similar behavior: ``` xrC = xr.DataArray(C, dims=('x','y'), coords={'x':x[15:n+15],'y':y[-n-10:-10]})

xrABC = xrA.combine_first(xrB).combine_first(xrC)

fig,ax = plt.subplots(figsize=(5,5)) xrABC.plot(ax=ax) ```

Is this a bug or a feature? If not a bug, how should I go about plotting my array data so that nan regions look as such?

Output of xr.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.6.3.final.0 python-bits: 64 OS: Darwin OS-release: 16.7.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 pandas: 0.20.3 numpy: 1.13.0 scipy: 0.18.1 netCDF4: None h5netcdf: None Nio: None bottleneck: 1.2.1 cyordereddict: None dask: 0.15.3 matplotlib: 2.0.0 cartopy: None seaborn: 0.8.0 setuptools: 36.5.0.post20170921 pip: 9.0.1 conda: 4.4.6 pytest: 3.2.1 IPython: 6.1.0 sphinx: 1.6.3
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/1862/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

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