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
415209776,MDU6SXNzdWU0MTUyMDk3NzY=,2791,formatting of singleton DataArrays,6164157,closed,0,,,8,2019-02-27T16:22:34Z,2023-12-02T02:44:06Z,2023-12-02T02:44:05Z,CONTRIBUTOR,,,,"#### Code Sample, a copy-pastable example if possible
```python
a=xr.DataArray(1.234)
'{:1.3f}'.format(a) # throws error
'{:1.3f}'.format(a.values) # behaves nicely
```
#### Problem description
I think it would be useful for `repr(a)` to return `repr(a.values)` when `a.ndim==0` and perhaps also when `a.size==1`. For example, this would make such code work:
```python
a=xr.DataArray(range(4))
' '.join('{:d}'.format(v) for v in a)
```
while currently one has to write
```python
' '.join('{:d}'.format(v.values) for v in a)
```
I tried to think whether this will break something else but I couldn't think of anything.
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/2791/reactions"", ""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
633516123,MDU6SXNzdWU2MzM1MTYxMjM=,4126,Bug in legend of dataset.plot.scatter,6164157,closed,0,,,3,2020-06-07T15:38:46Z,2020-09-13T08:33:15Z,2020-09-10T18:48:11Z,CONTRIBUTOR,,,,"
When using Dataset.scatter with hue being a variable of dtype string, the legend turns out to be wrong.
#### MCVE Code Sample
```python
import xarray as xr
import numpy as np
dd = xr.Dataset({'y': (['x'], np.arange(8)),
'label': (['x'], list('AABBCCDD'))},
coords={'x': np.linspace(0,1,8)})
dd.plot.scatter(x='x', y='y', hue='label')
```
Output is (note the legend):

Playing around it seems that it always chooses the first 4 values as the legend labels (note that the order of colors of the points is correct):
```python
import xarray as xr
import numpy as np
dd = xr.Dataset({'y': (['x'], np.arange(8)),
'label': (['x'], list('ABBACDDC'))},
coords={'x': np.linspace(0,1,8)})
dd.plot.scatter(x='x', y='y', hue='label')
```

And if there are only 3 labels in total it chooses the first 3:
```python
import xarray as xr
import numpy as np
dd = xr.Dataset({'y': (['x'], np.arange(6)),
'label': (['x'], list('ABBACC'))},
coords={'x': np.linspace(0,1,6)})
dd.plot.scatter(x='x', y='y', hue='label')
```

#### Expected Output
Legend in first two plots should read 'ABCD' and last plot 'ABC'
#### Versions
Output of xr.show_versions()
INSTALLED VERSIONS
------------------
commit: None
libhdf5: 1.10.4
libnetcdf: None
xarray: 0.15.1
pandas: 0.25.1
numpy: 1.17.2
scipy: 1.3.1
netCDF4: None
pydap: None
h5netcdf: None
h5py: 2.9.0
Nio: None
zarr: None
cftime: None
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: 1.2.1
dask: 2.5.2
distributed: 2.5.2
matplotlib: 3.1.1
cartopy: None
seaborn: 0.9.0
numbagg: None
setuptools: 41.4.0
pip: 19.2.3
conda: 4.8.1
pytest: 5.2.1
IPython: 7.8.0
sphinx: 2.2.0
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4126/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
407085814,MDU6SXNzdWU0MDcwODU4MTQ=,2748,Inconsistent name behavior in masking,6164157,closed,0,,,2,2019-02-06T05:25:47Z,2019-02-11T19:05:40Z,2019-02-11T19:05:40Z,CONTRIBUTOR,,,,"#### Code Sample, a copy-pastable example if possible
Consider the following 4 ways to mask an `DataArray`:
```python
import xarray as xr
ds=xr.Dataset({'a': (['x'], range(10))},
coords={'x': range(10)})
ds['msk']=ds.a>5
msk=ds.a>5
v1=ds.a.where(ds.a>5)
v2=ds.a.where(msk)
v3=ds.where(ds.msk).a
v4=ds.a.where(ds.msk)
', '.join(str(v.name) for v in (v1, v2, v3, v4))```
#output:
'a, a, a, None'
```
#### Problem description
All `v`s defined above are identical, except that `v4` has lost its name in masking. This can cause errors in merging (like just happened to me and was hard and annoying to catch).
Is this behavior intentional? It seems inconsistent to me that `ds.a.where(ds.msk)` is not equivalent to `ds.where(ds.msk).a`
#### Expected Output
I would expect `ds.a.where(ds.msk)` to return a `DataArray` with the name `a`.
#### Output of ``xr.show_versions()``
INSTALLED VERSIONS
------------------
commit: None
python: 3.7.2 (default, Dec 29 2018, 00:00:04)
[Clang 4.0.1 (tags/RELEASE_401/final)]
python-bits: 64
OS: Darwin
OS-release: 18.2.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
libhdf5: None
libnetcdf: None
xarray: 0.11.1+49.g27cf53f2
pandas: 0.23.3
numpy: 1.16.0
scipy: 1.2.0
netCDF4: None
pydap: None
h5netcdf: None
h5py: None
Nio: None
zarr: 2.2.0
cftime: 1.0.3.4
PseudonetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: 1.2.1
cyordereddict: None
dask: 1.1.0
distributed: 1.25.3
matplotlib: 3.0.2
cartopy: 0.17.0
seaborn: 0.9.0
setuptools: 40.8.0
pip: 19.0.1
conda: None
pytest: None
IPython: 7.2.0
sphinx: 1.8.2
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/2748/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
406615454,MDU6SXNzdWU0MDY2MTU0NTQ=,2743,Documentation fails to build,6164157,closed,0,,,5,2019-02-05T03:27:14Z,2019-02-06T16:56:48Z,2019-02-06T16:56:48Z,CONTRIBUTOR,,,,"I'm trying to build the doc and it fails. I have a fresh miniconda install with a test environment created as instructed in the docs (i.e. `conda env create -f ci/requirements-py36.yml` followed by `conda install -c conda-forge sphinx sphinx_rtd_theme sphinx-gallery numpydoc`).
#### Code Sample, a copy-pastable example if possible
```shell
make clean
make html
```
#### Problem description
It generates the following error:
```
Exception occurred:
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/IPython/sphinxext/ipython_directive.py"", line 567, in process_input
raise RuntimeError('Non Expected exception in `{}` line {}'.format(filename, lineno))
RuntimeError: Non Expected exception in `/Users/yohai/Dropbox/Coding/xarray/doc/io.rst` line 376
The full traceback has been saved in /var/folders/mj/g9tnmysj6zld_3dg6hm9tkk00000gn/T/sphinx-err-8q55qmxi.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at . Thanks!
make: *** [html] Error 2
```
The problem seems to be in `doc/io.rst`. When I delete all lines upto [line 367](https://github.com/pydata/xarray/blame/master/doc/io.rst#L367) it builds well
The content of the traceback logfile:
```
# Sphinx version: 1.8.4
# Python version: 3.6.7 (CPython)
# Docutils version: 0.14
# Jinja2 version: 2.10
# Last messages:
# reading sources... [ 97%] indexing
#
# reading sources... [ 97%] installing
#
# reading sources... [ 97%] internals
#
# reading sources... [ 97%] interpolation
#
# reading sources... [ 98%] io
#
# Loaded extensions:
# sphinx.ext.mathjax (1.8.4) from /Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/sphinx/ext/mathjax.py
# alabaster (0.7.12) from /Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/alabaster/__init__.py
# sphinx.ext.autodoc (1.8.4) from /Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/sphinx/ext/autodoc/__init__.py
# sphinx.ext.autosummary (1.8.4) from /Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/sphinx/ext/autosummary/__init__.py
# sphinx.ext.intersphinx (1.8.4) from /Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/sphinx/ext/intersphinx.py
# sphinx.ext.extlinks (1.8.4) from /Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/sphinx/ext/extlinks.py
# numpydoc (0.8.0) from /Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/numpydoc/__init__.py
# IPython.sphinxext.ipython_directive (unknown version) from /Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/IPython/sphinxext/ipython_directive.py
# IPython.sphinxext.ipython_console_highlighting (unknown version) from /Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/IPython/sphinxext/ipython_console_highlighting.py
# sphinx_gallery.gen_gallery (0.2.0) from /Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/sphinx_gallery/gen_gallery.py
Traceback (most recent call last):
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/sphinx/cmd/build.py"", line 304, in build_main
app.build(args.force_all, filenames)
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/sphinx/application.py"", line 341, in build
self.builder.build_update()
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/sphinx/builders/__init__.py"", line 347, in build_update
len(to_build))
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/sphinx/builders/__init__.py"", line 360, in build
updated_docnames = set(self.read())
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/sphinx/builders/__init__.py"", line 468, in read
self._read_serial(docnames)
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/sphinx/builders/__init__.py"", line 490, in _read_serial
self.read_doc(docname)
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/sphinx/builders/__init__.py"", line 534, in read_doc
doctree = read_doc(self.app, self.env, self.env.doc2path(docname))
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/sphinx/io.py"", line 318, in read_doc
pub.publish()
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/docutils/core.py"", line 217, in publish
self.settings)
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/docutils/readers/__init__.py"", line 72, in read
self.parse()
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/docutils/readers/__init__.py"", line 78, in parse
self.parser.parse(self.input, document)
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/sphinx/parsers.py"", line 88, in parse
self.statemachine.run(inputstring, document, inliner=self.inliner)
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/docutils/parsers/rst/states.py"", line 171, in run
input_source=document['source'])
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/docutils/statemachine.py"", line 239, in run
context, state, transitions)
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/docutils/statemachine.py"", line 460, in check_line
return method(match, context, next_state)
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/docutils/parsers/rst/states.py"", line 2753, in underline
self.section(title, source, style, lineno - 1, messages)
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/docutils/parsers/rst/states.py"", line 327, in section
self.new_subsection(title, lineno, messages)
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/docutils/parsers/rst/states.py"", line 395, in new_subsection
node=section_node, match_titles=True)
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/docutils/parsers/rst/states.py"", line 282, in nested_parse
node=node, match_titles=match_titles)
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/docutils/parsers/rst/states.py"", line 196, in run
results = StateMachineWS.run(self, input_lines, input_offset)
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/docutils/statemachine.py"", line 239, in run
context, state, transitions)
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/docutils/statemachine.py"", line 460, in check_line
return method(match, context, next_state)
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/docutils/parsers/rst/states.py"", line 2753, in underline
self.section(title, source, style, lineno - 1, messages)
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/docutils/parsers/rst/states.py"", line 327, in section
self.new_subsection(title, lineno, messages)
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/docutils/parsers/rst/states.py"", line 395, in new_subsection
node=section_node, match_titles=True)
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/docutils/parsers/rst/states.py"", line 282, in nested_parse
node=node, match_titles=match_titles)
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/docutils/parsers/rst/states.py"", line 196, in run
results = StateMachineWS.run(self, input_lines, input_offset)
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/docutils/statemachine.py"", line 239, in run
context, state, transitions)
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/docutils/statemachine.py"", line 460, in check_line
return method(match, context, next_state)
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/docutils/parsers/rst/states.py"", line 2326, in explicit_markup
nodelist, blank_finish = self.explicit_construct(match)
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/docutils/parsers/rst/states.py"", line 2338, in explicit_construct
return method(self, expmatch)
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/docutils/parsers/rst/states.py"", line 2081, in directive
directive_class, match, type_name, option_presets)
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/docutils/parsers/rst/states.py"", line 2130, in run_directive
result = directive_instance.run()
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/IPython/sphinxext/ipython_directive.py"", line 1005, in run
rows, figure = self.shell.process_block(block)
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/IPython/sphinxext/ipython_directive.py"", line 711, in process_block
self.process_input(data, input_prompt, lineno)
File ""/Users/yohai/miniconda3/envs/test_env/lib/python3.6/site-packages/IPython/sphinxext/ipython_directive.py"", line 567, in process_input
raise RuntimeError('Non Expected exception in `{}` line {}'.format(filename, lineno))
RuntimeError: Non Expected exception in `/Users/yohai/Dropbox/Coding/xarray/doc/io.rst` line 376
```
#### Output of ``xr.show_versions()``
xr.show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 3.6.7 | packaged by conda-forge | (default, Nov 20 2018, 18:37:09)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]
python-bits: 64
OS: Darwin
OS-release: 18.2.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
libhdf5: 1.10.4
libnetcdf: 4.6.2
xarray: 0.11.1+49.g27cf53f2
pandas: 0.24.1
numpy: 1.15.4
scipy: 1.2.0
netCDF4: 1.4.2
pydap: installed
h5netcdf: 0.6.2
h5py: 2.9.0
Nio: None
zarr: 2.2.0
cftime: 1.0.3.4
PseudonetCDF: None
rasterio: 1.0.15
cfgrib: 0.9.5.5
iris: None
bottleneck: 1.2.1
cyordereddict: None
dask: 1.1.1
distributed: 1.25.3
matplotlib: 3.0.2
cartopy: 0.17.0
seaborn: 0.9.0
setuptools: 40.7.1
pip: 19.0.1
conda: None
pytest: 4.2.0
IPython: 7.2.0
sphinx: 1.8.4
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/2743/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
342005194,MDU6SXNzdWUzNDIwMDUxOTQ=,2295,Broken link in doc,6164157,closed,0,,,1,2018-07-17T17:02:18Z,2018-07-17T20:01:28Z,2018-07-17T20:01:28Z,CONTRIBUTOR,,,,"The link to the external blogpost about xarray and dask, that was fixed in https://github.com/pydata/xarray/pull/1573, is broken again. Is it available somewhere?
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/2295/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
335123398,MDU6SXNzdWUzMzUxMjMzOTg=,2248,unnamed args in faceted line plots,6164157,closed,0,,,0,2018-06-23T19:02:17Z,2018-07-04T17:06:55Z,2018-07-04T17:06:54Z,CONTRIBUTOR,,,,"#### Code Sample, a copy-pastable example if possible
Unnamed arguments that are passed to line plots are directly passed to `plot`.
```python
import xarray as xr
import numpy as np
d3 = xr.DataArray(np.random.randn(10, 6, 3),
dims=['x', 'y', 'z'],
coords=[range(10), range(6), ['foo', 'bar', 'foobar']])
d2 = d3[..., 0].squeeze(drop=True)
# This will make triangle markers and dashed lines:
d2.plot.line('^--',x='x')
```
We [recently implemented ](https://github.com/pydata/xarray/pull/2107) faceted line plots:
```python
d3.plot(col='z', hue='x') #should work from commit `bc52f8a` onwards.
```
However, current implementation does not allow for passing of unnamed arguments:
```python
d3.plot('^--', col='z', hue='x') #gives error
d3.plot.line('^--', col='z', hue='x') #gives different error
```
I'd be happy to fix this (it's probably an easy fix, I didn't check) but I'm not sure what the correct user interface should be. Should `DataArray.plot` with `hue` as a keyword behave identically to `DataArray.plot.line`? ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/2248/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
317853953,MDU6SXNzdWUzMTc4NTM5NTM=,2084,New Feature: Add FacetGrid functionality to plot.line(),6164157,closed,0,,,5,2018-04-26T02:18:41Z,2018-06-15T05:13:40Z,2018-06-15T05:13:40Z,CONTRIBUTOR,,,,"When data is more than 2 dimensional, `plot()` creates a `FacetGrid` where each facet gets plots two dimensional data. I would find it very useful to have similar functionality for line plots.
Let's define three `DataArray`s, of 2,3 and 4 dimensions, named `d2`, `d3` and `d4`.
```python
d4=xr.DataArray(np.random.randn(3,4,5,6),
dims=['x','y','z','w'],
coords=[range(3),range(4),range(5),range(6)])
d3=d4[...,0].drop('w')
d2=d3[...,0].drop('z')
d4.plot(row='x', col='y') #creates a 2d facet grid, each facet is a pcolormesh
d3.plot(col='x') #creates a 1d facet grid, each facet is a pcolormesh
plt.show()
```
It would be very useful to have a similar interface for `line` plots too. That is, I would expect
```python
d2.plot.line(row='y', x='x')
```
to create a row of panels, each having one line. Similarly, I would expect
```python
d3.plot.line(col='y', x='x')
#or alternatively
d3.plot.line(col='y', hue='z')
```
to create a row of panels, each having a series of lines, with `hue` corresponding to `z` and so forth. Finally,
```python
d4.plot.line(row='z',col='y', x='x')
#or alternatively
d4.plot.line(row='z',col='y', hue='w')
```
should create a 2d matrix of panels, each having a series of lines, with `hue` corresponding to `w`.
This seems to me like a natural generalization of the behaviour of `plot()`, and I found myself coding manually loops to do that a few times.
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/2084/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue