home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 675288247

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
675288247 MDU6SXNzdWU2NzUyODgyNDc= 4322 "_center" postfix on axis label resulting from groupby_bins persists after renaming variable 23484003 closed 0     5 2020-08-07T21:01:19Z 2021-01-12T16:44:49Z 2021-01-12T16:44:49Z NONE      

What happened:

I used groupby_bins + sum to reduce the resolution of my dataset along 'x' dimension. I didn't like the 'x_bins_center' label, so I renamed the x-axis dim/coord to simply 'x.' However, the "_center" postfix is not part of the variable name -- it appears to be some tweaking of the x-axis label when plotting. So now I am stuck with "_center" tagged at the end of the x-axis label, even after the units.

What you expected to happen:

It would make more sense if the '_center' were part of the variable name. That way, the name displayed on the plot is the same one that I need to access the variable in the dataset. Also, when I rename the variable, I will be able to change the way it displays. Furthermore, that will prevent the issue with "_center" getting pasted on after the units.

Minimal Complete Verifiable Example:

```python

import xarray as xr import numpy as np data_vars={'y':('x',np.ones((101)),{'units':'kg/m'})} coords={'x':('x',np.linspace(0,1,101,endpoint=True),{'units':'m'})} ds = xr.Dataset(data_vars,coords) dsd = ds.groupby_bins('x',np.linspace(0,1,11,endpoint=True),right=False).sum(dim='x') dsd.y.plot() #Shows that the x-axis is named "x_bins_center" dsd = dsd.rename({'x_bins_center':'x'}) #Fails:

ValueError: cannot rename 'x_bins_center' because it is not a variable or dimension in this dataset dsd = dsd.rename({'x_bins':'x'}) #Succeeds, b/c the variable is ACTUALLY named 'x_bins' dsd.x.attrs['units']='m' dsd.y.plot() #x-axis label is "x [m]_center" -- there's a sneaky renaming thing that is appending _center to the end of the label

```

Anything else we need to know?:

Plots Here's the 1st plot showing the default x-axis label prior to renaming: ![Original_plot](https://user-images.githubusercontent.com/23484003/89687789-aa88e580-d8b5-11ea-9553-a497eff5f238.png) Here's the 2nd plot showing the mangled x-axis label after I renamed the variable & reestablished the units: ![Butchered_plot](https://user-images.githubusercontent.com/23484003/89687915-efad1780-d8b5-11ea-9348-f7016325e377.png)

Environment:

Output of <tt>xr.show_versions()</tt> INSTALLED VERSIONS ------------------ commit: None python: 3.7.7 (default, Mar 23 2020, 17:31:31) [Clang 4.0.1 (tags/RELEASE_401/final)] python-bits: 64 OS: Darwin OS-release: 19.6.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: en_US.UTF-8 LANG: en_US.UTF-8 LOCALE: en_US.UTF-8 libhdf5: 1.10.4 libnetcdf: 4.6.1 xarray: 0.16.0 pandas: 1.0.3 numpy: 1.18.1 scipy: 1.4.1 netCDF4: 1.4.2 pydap: None h5netcdf: 0.8.0 h5py: 2.10.0 Nio: None zarr: None cftime: 1.2.1 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: 2.20.0 distributed: None matplotlib: 3.1.3 cartopy: None seaborn: None numbagg: None pint: 0.11 setuptools: 49.2.0.post20200714 pip: 20.1.1 conda: None pytest: 5.4.1 IPython: 7.13.0 sphinx: 3.1.2
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/4322/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
  • 5 rows from issue in issue_comments
Powered by Datasette · Queries took 1.04ms · About: xarray-datasette