html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue
https://github.com/pydata/xarray/issues/7552#issuecomment-1494018319,https://api.github.com/repos/pydata/xarray/issues/7552,1494018319,IC_kwDOAMm_X85ZDOkP,85181086,2023-04-03T09:51:16Z,2023-04-08T11:37:40Z,NONE,"The reason why you are getting a KeyError in your first example when trying to plot with col='y' is because when y is a dimension with length 1, xarray automatically drops the dimension and promotes its coordinates to 1D.
In your example, the y dimension has length 1, so it is dropped, and da.coords['y'] returns a scalar value rather than a 1D coordinate array. When you try to plot with col='y', xarray looks for the 'y' key in the coordinates dictionary, which doesn't exist, hence the KeyError.
To work around this, you can manually promote the y coordinate to a 1D array using the expand_dims method:
```
import xarray as xr
import numpy as np
da = xr.DataArray(np.random.rand(3,1), dims=('x', 'y'))
da.coords['y'] = da.coords['y'].expand_dims('y')
da.plot(col='y')
```
This will ensure that the y coordinate is always a 1D array, even when the dimension it represents has length 1.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1596890616