home / github

Menu
  • Search all tables
  • GraphQL API

issues

Table actions
  • GraphQL API for issues

1 row where user = 6588826 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

Suggested facets: created_at (date), updated_at (date), closed_at (date)

type 1

  • issue 1

state 1

  • closed 1

repo 1

  • xarray 1
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
628089013 MDU6SXNzdWU2MjgwODkwMTM= 4115 DataArray.plot.line color kwarg martintb 6588826 closed 0     2 2020-06-01T01:14:17Z 2020-06-01T19:43:54Z 2020-06-01T19:43:54Z NONE      

matplotlib.colors throws ValueError when a list of colors is passed to xr.DataArray.plot.line

MCVE Code Sample

```python import matplotlib import matplotlib.colors import matplotlib.cm import xarray as xr import numpy as np

data = np.random.random((10,10)) x = np.arange(0,1.0,0.1) y = np.arange(0,100,10.0)

norm = matplotlib.colors.Normalize(vmin=y.min(),vmax=y.max()) cmapper = matplotlib.cm.ScalarMappable(norm=norm,cmap=matplotlib.cm.viridis).to_rgba

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

da.plot.line(x='x',color=cmapper(da.y.values)) #throws ValueError in matplotlib/colors.py

da.to_pandas().plot(color=cmapper(da.y.values)) ```

Expected Output

Problem Description

I need to be able to map coordinate values to colors so that data plotted from different arrays are always aligned in colorspace. Depending on the data, specific y-values may be missing so a simple color cycle doesn't work here unfortunately. Passing a list of colors to pandas.plot seems to work but not for xarray.plot. While the obvious workaround is to cast to pandas, is there something I can do to make this work for xarray?

Versions

Output of <tt>xr.show_versions()</tt> INSTALLED VERSIONS ------------------ commit: None python: 3.7.6 | packaged by conda-forge | (default, Mar 23 2020, 22:45:16) [Clang 9.0.1 ] python-bits: 64 OS: Darwin OS-release: 19.4.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8 libhdf5: 1.10.5 libnetcdf: 4.7.3 xarray: 0.15.1 pandas: 1.0.3 numpy: 1.18.4 scipy: 1.4.1 netCDF4: 1.5.3 pydap: None h5netcdf: None h5py: 2.10.0 Nio: None zarr: None cftime: 1.1.1.1 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: 2.12.0 distributed: None matplotlib: 3.2.1 cartopy: None seaborn: 0.10.1 numbagg: None setuptools: 47.1.0.post20200528 pip: 20.1.1 conda: None pytest: None IPython: 7.13.0 sphinx: None
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/4115/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed xarray 13221727 issue

Advanced export

JSON shape: default, array, newline-delimited, object

CSV options:

CREATE TABLE [issues] (
   [id] INTEGER PRIMARY KEY,
   [node_id] TEXT,
   [number] INTEGER,
   [title] TEXT,
   [user] INTEGER REFERENCES [users]([id]),
   [state] TEXT,
   [locked] INTEGER,
   [assignee] INTEGER REFERENCES [users]([id]),
   [milestone] INTEGER REFERENCES [milestones]([id]),
   [comments] INTEGER,
   [created_at] TEXT,
   [updated_at] TEXT,
   [closed_at] TEXT,
   [author_association] TEXT,
   [active_lock_reason] TEXT,
   [draft] INTEGER,
   [pull_request] TEXT,
   [body] TEXT,
   [reactions] TEXT,
   [performed_via_github_app] TEXT,
   [state_reason] TEXT,
   [repo] INTEGER REFERENCES [repos]([id]),
   [type] TEXT
);
CREATE INDEX [idx_issues_repo]
    ON [issues] ([repo]);
CREATE INDEX [idx_issues_milestone]
    ON [issues] ([milestone]);
CREATE INDEX [idx_issues_assignee]
    ON [issues] ([assignee]);
CREATE INDEX [idx_issues_user]
    ON [issues] ([user]);
Powered by Datasette · Queries took 22.33ms · About: xarray-datasette