home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 633516123

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
633516123 MDU6SXNzdWU2MzM1MTYxMjM= 4126 Bug in legend of dataset.plot.scatter 6164157 closed 0     3 2020-06-07T15:38:46Z 2020-09-13T08:33:15Z 2020-09-10T18:48:11Z CONTRIBUTOR      

When using Dataset.scatter with hue being a variable of dtype string, the legend turns out to be wrong.

MCVE Code Sample

python import xarray as xr import numpy as np dd = xr.Dataset({'y': (['x'], np.arange(8)), 'label': (['x'], list('AABBCCDD'))}, coords={'x': np.linspace(0,1,8)}) dd.plot.scatter(x='x', y='y', hue='label') Output is (note the legend):

Playing around it seems that it always chooses the first 4 values as the legend labels (note that the order of colors of the points is correct): python import xarray as xr import numpy as np dd = xr.Dataset({'y': (['x'], np.arange(8)), 'label': (['x'], list('ABBACDDC'))}, coords={'x': np.linspace(0,1,8)}) dd.plot.scatter(x='x', y='y', hue='label')

And if there are only 3 labels in total it chooses the first 3: python import xarray as xr import numpy as np dd = xr.Dataset({'y': (['x'], np.arange(6)), 'label': (['x'], list('ABBACC'))}, coords={'x': np.linspace(0,1,6)}) dd.plot.scatter(x='x', y='y', hue='label')

Expected Output

Legend in first two plots should read 'ABCD' and last plot 'ABC'

Versions

Output of <tt>xr.show_versions()</tt> INSTALLED VERSIONS ------------------ commit: None libhdf5: 1.10.4 libnetcdf: None xarray: 0.15.1 pandas: 0.25.1 numpy: 1.17.2 scipy: 1.3.1 netCDF4: None pydap: None h5netcdf: None h5py: 2.9.0 Nio: None zarr: None cftime: None nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: 1.2.1 dask: 2.5.2 distributed: 2.5.2 matplotlib: 3.1.1 cartopy: None seaborn: 0.9.0 numbagg: None setuptools: 41.4.0 pip: 19.2.3 conda: 4.8.1 pytest: 5.2.1 IPython: 7.8.0 sphinx: 2.2.0
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/4126/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
  • 3 rows from issue in issue_comments
Powered by Datasette · Queries took 0.594ms · About: xarray-datasette