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
[X] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
[X] Complete example — the example is self-contained, including all data and the text of any traceback.
[X] Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
[X] New issue — a search of GitHub Issues suggests this is not a duplicate.
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
andc
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 tobnds
.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
MVCE confirmation
Relevant log output
No response
Anything else we need to know?
Environment