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/4061#issuecomment-629695308,https://api.github.com/repos/pydata/xarray/issues/4061,629695308,MDEyOklzc3VlQ29tbWVudDYyOTY5NTMwOA==,10194086,2020-05-16T19:30:14Z,2020-05-16T19:30:14Z,MEMBER,"That's probably gonna need a `extend=""both""`","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,618141254
https://github.com/pydata/xarray/issues/4061#issuecomment-629387430,https://api.github.com/repos/pydata/xarray/issues/4061,629387430,MDEyOklzc3VlQ29tbWVudDYyOTM4NzQzMA==,10194086,2020-05-15T17:33:33Z,2020-05-15T17:33:33Z,MEMBER,"If you use
```python
norm = colors.BoundaryNorm(boundaries=bounds, ncolors=9)
```
it works. A new norm with `ncolors=9` is built in `_build_discrete_cmap` - however, it is not used as `norm` is already defined:
https://github.com/pydata/xarray/blob/2542a63f6ebed1a464af7fc74b9f3bf302925803/xarray/plot/utils.py#L290-L292
The fix might be to use:
```python
if levels is not None or isinstance(norm, mpl.colors.BoundaryNorm):
cmap, norm = _build_discrete_cmap(cmap, levels, extend, filled)
```
this breaks one test which is probably fixable (it tests that the norm is not changed when it is given).
Note that mpl seems to use a `LinearSegmentedColormap` while xarray creates a `ListedColormap`.
","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,618141254
https://github.com/pydata/xarray/issues/4061#issuecomment-629197481,https://api.github.com/repos/pydata/xarray/issues/4061,629197481,MDEyOklzc3VlQ29tbWVudDYyOTE5NzQ4MQ==,10194086,2020-05-15T12:05:39Z,2020-05-15T12:05:39Z,MEMBER,"What should also work is `img = ds['var'].plot(ax=ax, cmap=cmap, levels=levels)`","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,618141254