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/866#issuecomment-223709530,https://api.github.com/repos/pydata/xarray/issues/866,223709530,MDEyOklzc3VlQ29tbWVudDIyMzcwOTUzMA==,10050469,2016-06-03T22:26:50Z,2016-06-03T23:08:25Z,MEMBER,"@shoyer I thought that the colorbar was not very meaningful for contours, but I changed my mind.
[EDIT] I just updated the PR again. See the following example generated with the PR branch:
``` python
import numpy as np
import matplotlib.pyplot as plt
import xarray as xr
x, y = np.meshgrid(np.arange(12), np.arange(12))
z = xr.DataArray(np.sqrt(x**2 + y**2))
ds = z.to_dataset(name='z')
f, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, figsize=(6, 6))
ds.z.plot.contour(ax=ax1, levels=[4])
ds.z.plot.contour(ax=ax2, levels=[-1, 2, 4, 6, 8])
ds.z.plot.contour(ax=ax3, levels=[4], colors=['k'])
ds.z.plot.contour(ax=ax4, levels=[2, 4, 6, 8], colors=['k', 'r', 'g', 'b'])
plt.tight_layout()
plt.show()
```

I think it's ok now, and the 1-level examples now run just fine.
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,158212793
https://github.com/pydata/xarray/issues/866#issuecomment-223702739,https://api.github.com/repos/pydata/xarray/issues/866,223702739,MDEyOklzc3VlQ29tbWVudDIyMzcwMjczOQ==,1217238,2016-06-03T21:47:19Z,2016-06-03T21:47:19Z,MEMBER,"@fmaussion I would agree that if you pick a fixed color, then `add_colorbar=False` is a more sensible default choice. Why do you think that's a better choice in general?
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,158212793
https://github.com/pydata/xarray/issues/866#issuecomment-223646763,https://api.github.com/repos/pydata/xarray/issues/866,223646763,MDEyOklzc3VlQ29tbWVudDIyMzY0Njc2Mw==,7300413,2016-06-03T17:49:22Z,2016-06-03T17:49:22Z,NONE,"Oh, not really! thanks for the fix :)
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,158212793
https://github.com/pydata/xarray/issues/866#issuecomment-223638374,https://api.github.com/repos/pydata/xarray/issues/866,223638374,MDEyOklzc3VlQ29tbWVudDIyMzYzODM3NA==,10050469,2016-06-03T17:16:14Z,2016-06-03T17:16:14Z,MEMBER,"This [PR](https://github.com/pydata/xarray/pull/868) should fix the issue. I now realize you were maybe willing to submit your own fix @JoyMonteiro ? Sorry if that was the case I can retract my PR.
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,158212793
https://github.com/pydata/xarray/issues/866#issuecomment-223629831,https://api.github.com/repos/pydata/xarray/issues/866,223629831,MDEyOklzc3VlQ29tbWVudDIyMzYyOTgzMQ==,7300413,2016-06-03T16:40:41Z,2016-06-03T16:40:41Z,NONE,"Just repeating your example, but with
``` python
z.plot.contour(ax=ax1, norm=None, **kw)
```
gives the expected

for some reason, the norm is causing an issue.
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,158212793
https://github.com/pydata/xarray/issues/866#issuecomment-223628261,https://api.github.com/repos/pydata/xarray/issues/866,223628261,MDEyOklzc3VlQ29tbWVudDIyMzYyODI2MQ==,10050469,2016-06-03T16:34:26Z,2016-06-03T16:36:12Z,MEMBER,"Actually there are a couple of other things which are not OK with xarray's `contour`. For example:
``` python
import numpy as np
import matplotlib.pyplot as plt
import xarray as xr
x, y = np.meshgrid(np.arange(12), np.arange(12))
z = xr.DataArray(np.sqrt(x**2 + y**2))
kw = {'levels':[2, 4, 6, 8], 'colors':['k']}
f, (ax1, ax2) = plt.subplots(1, 2, figsize=(6, 3))
z.plot.contour(ax=ax1, **kw)
ax2.contour(z.values, **kw)
plt.show()
```

I'll try to have a look at what's going on. @xarraydevs, do you agree that `add_colorbar` should default to `false` when `contour` is used?
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,158212793
https://github.com/pydata/xarray/issues/866#issuecomment-223522352,https://api.github.com/repos/pydata/xarray/issues/866,223522352,MDEyOklzc3VlQ29tbWVudDIyMzUyMjM1Mg==,7300413,2016-06-03T08:34:58Z,2016-06-03T08:34:58Z,NONE,"Yes, I had encountered that as well, but did not realise it was due to the colorbar... I normally don't use the colorbar. Thanks for the example!
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,158212793
https://github.com/pydata/xarray/issues/866#issuecomment-223520490,https://api.github.com/repos/pydata/xarray/issues/866,223520490,MDEyOklzc3VlQ29tbWVudDIyMzUyMDQ5MA==,10050469,2016-06-03T08:26:00Z,2016-06-03T08:26:00Z,MEMBER,"Here's a mwe:
``` python
import numpy as np
import matplotlib.pyplot as plt
import xarray as xr
x, y = np.meshgrid(np.arange(12), np.arange(12))
z = xr.DataArray(x**2 + y**2)
z.plot.contour(levels=[10], add_colorbar=False)
```
which indeed doesn't plot anything.
Note that without `add_colorbar=False`, it crashes with:
``` python
Traceback (most recent call last):
File """", line 1, in
File ""/home/mowglie/.pyvirtualenvs/oggm_pycharm/lib/python3.4/site-packages/xarray/plot/plot.py"", line 452, in plotmethod
return newplotfunc(**allargs)
File ""/home/mowglie/.pyvirtualenvs/oggm_pycharm/lib/python3.4/site-packages/xarray/plot/plot.py"", line 426, in newplotfunc
cbar = plt.colorbar(primitive, ax=ax, extend=cmap_params['extend'])
File ""/home/mowglie/.pyvirtualenvs/oggm_pycharm/lib/python3.4/site-packages/matplotlib/pyplot.py"", line 2237, in colorbar
ret = gcf().colorbar(mappable, cax = cax, ax=ax, **kw)
File ""/home/mowglie/.pyvirtualenvs/oggm_pycharm/lib/python3.4/site-packages/matplotlib/figure.py"", line 1595, in colorbar
cb = cbar.colorbar_factory(cax, mappable, **kw)
File ""/home/mowglie/.pyvirtualenvs/oggm_pycharm/lib/python3.4/site-packages/matplotlib/colorbar.py"", line 1330, in colorbar_factory
cb = Colorbar(cax, mappable, **kwargs)
File ""/home/mowglie/.pyvirtualenvs/oggm_pycharm/lib/python3.4/site-packages/matplotlib/colorbar.py"", line 895, in __init__
ColorbarBase.__init__(self, ax, **kw)
File ""/home/mowglie/.pyvirtualenvs/oggm_pycharm/lib/python3.4/site-packages/matplotlib/colorbar.py"", line 323, in __init__
self.draw_all()
File ""/home/mowglie/.pyvirtualenvs/oggm_pycharm/lib/python3.4/site-packages/matplotlib/colorbar.py"", line 346, in draw_all
X, Y = self._mesh()
File ""/home/mowglie/.pyvirtualenvs/oggm_pycharm/lib/python3.4/site-packages/matplotlib/colorbar.py"", line 812, in _mesh
y = self._uniform_y(self._central_N())
File ""/home/mowglie/.pyvirtualenvs/oggm_pycharm/lib/python3.4/site-packages/matplotlib/colorbar.py"", line 749, in _uniform_y
automin = automax = 1. / (N - 1.)
ZeroDivisionError: float division by zero
```
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,158212793