issues: 1521002414
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1521002414 | I_kwDOAMm_X85aqKeu | 7422 | `plot.scatter` only works for declared arguments | 5797727 | closed | 0 | 2 | 2023-01-05T16:15:28Z | 2023-01-05T22:39:23Z | 2023-01-05T22:39:23Z | NONE | What happened?
returns: ```pythonKeyError Traceback (most recent call last) File /autofs/nas1/home/isimoesdesousa/programs/mambaforge/envs/coringa/lib/python3.9/site-packages/xarray/core/dataset.py:1340, in Dataset._construct_dataarray(self, name) 1339 try: -> 1340 variable = self._variables[name] 1341 except KeyError: KeyError: None During handling of the above exception, another exception occurred: KeyError Traceback (most recent call last) Cell In[60], line 1 ----> 1 ds.plot.scatter("x","y") File /autofs/nas1/home/isimoesdesousa/programs/mambaforge/envs/coringa/lib/python3.9/site-packages/xarray/plot/accessor.py:1071, in DatasetPlotAccessor.scatter(self, args, kwargs) 1069 @functools.wraps(dataset_plot.scatter) 1070 def scatter(self, args, kwargs) -> PathCollection | FacetGrid[DataArray]: -> 1071 return dataset_plot.scatter(self._ds, *args, kwargs) File /autofs/nas1/home/isimoesdesousa/programs/mambaforge/envs/coringa/lib/python3.9/site-packages/xarray/plot/dataset_plot.py:914, in scatter(ds, x, y, z, hue, hue_style, markersize, linewidth, figsize, size, aspect, ax, row, col, col_wrap, xincrease, yincrease, add_legend, add_colorbar, add_labels, add_title, subplot_kws, xscale, yscale, xticks, yticks, xlim, ylim, cmap, vmin, vmax, norm, extend, levels, args, kwargs) 912 del locals_["ds"] 913 locals_.update(locals_.pop("kwargs", {})) --> 914 da = temp_dataarray(ds, y, locals) 916 return da.plot.scatter(locals_.pop("args", ()), **locals_) File /autofs/nas1/home/isimoesdesousa/programs/mambaforge/envs/coringa/lib/python3.9/site-packages/xarray/plot/dataset_plot.py:740, in temp_dataarray(ds, y, locals) 736 coords[key] = ds[key] 738 # The dataarray has to include all the dims. Broadcast to that shape 739 # and add the additional coords: --> 740 _y = ds[y].broadcast_like(ds) 742 return DataArray(_y, coords=coords) File /autofs/nas1/home/isimoesdesousa/programs/mambaforge/envs/coringa/lib/python3.9/site-packages/xarray/core/dataset.py:1431, in Dataset.getitem(self, key) 1429 return self.isel(**key) 1430 if utils.hashable(key): -> 1431 return self._construct_dataarray(key) 1432 if utils.iterable_of_hashable(key): 1433 return self._copy_listed(key) File /autofs/nas1/home/isimoesdesousa/programs/mambaforge/envs/coringa/lib/python3.9/site-packages/xarray/core/dataset.py:1342, in Dataset.construct_dataarray(self, name) 1340 variable = self._variables[name] 1341 except KeyError: -> 1342 , name, variable = _get_virtual_variable(self._variables, name, self.dims) 1344 needed_dims = set(variable.dims) 1346 coords: dict[Hashable, Variable] = {} File /autofs/nas1/home/isimoesdesousa/programs/mambaforge/envs/coringa/lib/python3.9/site-packages/xarray/core/dataset.py:174, in _get_virtual_variable(variables, key, dim_sizes) 171 return key, key, variable 173 if not isinstance(key, str): --> 174 raise KeyError(key) 176 split_key = key.split(".", 1) 177 if len(split_key) != 2: KeyError: None ``` What did you expect to happen?To plot the figure: Minimal Complete Verifiable Example```Python import pandas as pd n = 1000 df = pd.DataFrame() df["x"] = np.random.randn(n) df["y"] = np.random.randn(n) ds = df.to_xarray() this worksds.plot.scatter(x="x",y="y") this doesn't workds.plot.scatter("x","y") ``` MVCE confirmation
Relevant log outputNo response Anything else we need to know?No response Environment
NSTALLED VERSIONS
------------------
commit: None
python: 3.9.15 | packaged by conda-forge | (main, Nov 22 2022, 15:55:03)
[GCC 10.4.0]
python-bits: 64
OS: Linux
OS-release: 5.15.0-50-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: ('en_US', 'UTF-8')
libhdf5: 1.12.2
libnetcdf: 4.8.1
xarray: 2022.12.0
pandas: 1.5.2
numpy: 1.24.0
scipy: 1.9.3
netCDF4: 1.6.2
pydap: None
h5netcdf: None
h5py: None
Nio: None
zarr: None
cftime: 1.6.2
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: 1.3.5
dask: 2022.12.1
distributed: 2022.12.1
matplotlib: 3.6.2
cartopy: None
seaborn: None
numbagg: None
fsspec: 2022.11.0
cupy: None
pint: None
sparse: None
flox: None
numpy_groupies: None
setuptools: 65.6.3
pip: 22.3.1
conda: None
pytest: None
mypy: None
IPython: 8.7.0
sphinx: None
|
{ "url": "https://api.github.com/repos/pydata/xarray/issues/7422/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |