Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scatter plot infers weird default values #7314

Closed
4 tasks done
huard opened this issue Nov 23, 2022 · 2 comments · Fixed by #7277
Closed
4 tasks done

Scatter plot infers weird default values #7314

huard opened this issue Nov 23, 2022 · 2 comments · Fixed by #7277

Comments

@huard
Copy link
Contributor

huard commented Nov 23, 2022

What happened?

The xarray.plot.scatter method has changed its behavior in 2022.10.0. Code that used to work now doesn't.

The issue seems to be related to default values for the size and hue of markers. Instead of using s and c arguments, xarray tries to infer DataArrays to use, but picks non-sensical values.

What did you expect to happen?

A scatter plot with default size and color for markers.
Now xarray has inferred that the size is somehow related to the j dimension, and the hue to bnds.

Note that the calculations required to draw the figure with those defaults take a huge amount of time. In the example below, I've subsetted the file so the code runs in a short time. Without subsetting, it runs forever.

Minimal Complete Verifiable Example

import xarray as xr
from matplotlib import pyplot as plt
url = "https://pavics.ouranos.ca/twitcher/ows/proxy/thredds/dodsC/birdhouse/testdata/xclim/cmip6/sic_SImon_CCCma-CanESM5_ssp245_r13i1p2f1_2020.nc"
ds = xr.open_dataset(url)
t = ds.isel(i=slice(0,10), j=slice(0,11))
t.plot.scatter(x="longitude", y="latitude", s=1)
plt.show()

MVCE confirmation

  • Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
  • Complete example — the example is self-contained, including all data and the text of any traceback.
  • Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
  • New issue — a search of GitHub Issues suggests this is not a duplicate.

Relevant log output

No response

Anything else we need to know?

image

Environment

INSTALLED VERSIONS

commit: None
python: 3.10.4 | packaged by conda-forge | (main, Mar 24 2022, 17:39:04) [GCC 10.3.0]
python-bits: 64
OS: Linux
OS-release: 5.4.0-131-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_CA.UTF-8
LOCALE: ('en_CA', 'UTF-8')
libhdf5: 1.10.4
libnetcdf: 4.7.3
xarray: 2022.10.0
pandas: 1.4.3
numpy: 1.21.4
scipy: None
netCDF4: 1.5.7
pydap: None
h5netcdf: None
h5py: None
Nio: None
zarr: None
cftime: 1.5.1.1
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: 1.3.5
dask: 2022.7.0
distributed: None
matplotlib: 3.6.2
cartopy: None
seaborn: None
numbagg: None
fsspec: 2022.5.0
cupy: None
pint: 0.20.1
sparse: None
flox: None
numpy_groupies: None
setuptools: 62.6.0
pip: 22.0.4
conda: None
pytest: 7.1.2

@huard huard added bug needs triage Issue that has not been reviewed by xarray team member labels Nov 23, 2022
@headtr1ck headtr1ck added regression topic-plotting and removed bug needs triage Issue that has not been reviewed by xarray team member labels Nov 23, 2022
@headtr1ck
Copy link
Collaborator

Possibly related conversation: #7277 (comment)

@keewis
Copy link
Collaborator

keewis commented Nov 23, 2022

also related: #7268

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants