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/pull/1171#issuecomment-270094486,https://api.github.com/repos/pydata/xarray/issues/1171,270094486,MDEyOklzc3VlQ29tbWVudDI3MDA5NDQ4Ng==,10050469,2017-01-03T11:20:17Z,2017-01-03T11:20:17Z,MEMBER,"OK, so thanks to https://github.com/pydata/xarray/pull/1191 the required changes for the tests to pass in mpl v2 are minimal:
- deprecation of ``get_axis_bgcolor``
- ``test_num_ticks`` also changed due to changes in ``MaxNLocator``, but this is not a big deal
This is ready for review / merge","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,196278181
https://github.com/pydata/xarray/pull/1171#issuecomment-269556898,https://api.github.com/repos/pydata/xarray/issues/1171,269556898,MDEyOklzc3VlQ29tbWVudDI2OTU1Njg5OA==,10050469,2016-12-28T23:17:02Z,2016-12-28T23:17:02Z,MEMBER,"@shoyer
> if neither are set, then perhaps we should differ to whatever matplotlib defaults to
AFAIK, there is no logic for ``nlevels=int`` in mpl. Furthermore, mpl uses ``vmin`` and ``vmax`` to clip the data (not to decide upon the levels), which is undesirable for us.
However, the default mpl behavior when no levels are set is to call the private method [_autolev](https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/contour.py#L1119) which has a logic based on ``MaxNLocator`` too.
Long story short: I'll start another PR to address this problem specifically and then go back to MPL2 later on.
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,196278181
https://github.com/pydata/xarray/pull/1171#issuecomment-269553953,https://api.github.com/repos/pydata/xarray/issues/1171,269553953,MDEyOklzc3VlQ29tbWVudDI2OTU1Mzk1Mw==,10050469,2016-12-28T22:49:46Z,2016-12-28T22:51:27Z,MEMBER,"@efiring thanks for jumping in! I understand and I see that xarray is kind of misusing this tool, we'll change this in this PR.
In the test above ``MaxNLocator`` returns N+2 ticks though.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,196278181
https://github.com/pydata/xarray/pull/1171#issuecomment-269550777,https://api.github.com/repos/pydata/xarray/issues/1171,269550777,MDEyOklzc3VlQ29tbWVudDI2OTU1MDc3Nw==,10050469,2016-12-28T22:23:30Z,2016-12-28T22:23:30Z,MEMBER,"@QuLogic : thanks, and sorry for the noise.
@shoyer : should we use ``linspace`` only if ``vmax`` and/or ``vmin`` are set explicitly, or always? ``MaxNLocator`` definitely makes ""nicer"" levels, but as stated by the name it might choose less than N levels if needed...
On a side note, I already encountered this problem with my students before: what most users will do in this case is to set ``levels=np.linspace(foo, bar)`` themselves","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,196278181
https://github.com/pydata/xarray/pull/1171#issuecomment-269548536,https://api.github.com/repos/pydata/xarray/issues/1171,269548536,MDEyOklzc3VlQ29tbWVudDI2OTU0ODUzNg==,10050469,2016-12-28T22:05:29Z,2016-12-28T22:05:29Z,MEMBER,"I've found this [ticket](https://github.com/matplotlib/matplotlib/issues/7578), but it's not clear to me if the problem is solved or not. I'll have to test against mpl2 master I guess...
@QuLogic do you maybe have a moment to have a look at my comment above?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,196278181
https://github.com/pydata/xarray/pull/1171#issuecomment-269546930,https://api.github.com/repos/pydata/xarray/issues/1171,269546930,MDEyOklzc3VlQ29tbWVudDI2OTU0NjkzMA==,10050469,2016-12-28T21:52:38Z,2016-12-28T21:52:38Z,MEMBER,"> I think this is a bug
Yes, I should've looked into this in more detail. So the problem is [here](https://github.com/pydata/xarray/blob/master/xarray/plot/utils.py#L191). ``MaxNLocator.tick_values(vmin, vmax)`` does not guarantee to land on ``vmin`` or ``vmax`` exactly, which I think is confusing. It should be either changed or documented in xarray. The change could look like: if ``vmin`` and ``vmax`` are set _explicitely_, than we use ``linspace`` to build the levels.
Furthermore, ``MaxNLocator`` is no longer guaranteed to return a max of N levels in MPLv2, as shown by this simple test:
```python
import matplotlib as mpl
ticker = mpl.ticker.MaxNLocator(7)
levels = ticker.tick_values(4, 8)
print('mpl: {}, nlevels: {}, levels: {}'.format(mpl.__version__, len(levels), levels))
```
Which prints, depending on mpl version:
```
mpl: 1.5.3, nlevels: 7, levels: [ 3.2 4. 4.8 5.6 6.4 7.2 8. ]
```
```
mpl: 2.0.0rc2, nlevels: 9, levels: [ 3.6 4.2 4.8 5.4 6. 6.6 7.2 7.8 8.4]
```
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,196278181
https://github.com/pydata/xarray/pull/1171#issuecomment-269312214,https://api.github.com/repos/pydata/xarray/issues/1171,269312214,MDEyOklzc3VlQ29tbWVudDI2OTMxMjIxNA==,10050469,2016-12-27T11:12:37Z,2016-12-27T11:12:37Z,MEMBER,"This fixes the failing tests on MPL2. Two of the tests were failing because of how mpl chooses to do things, which makes me think that the tests are not very robust. My fixes are also rather simple...
For example the ``test_discrete_colormap_int_levels`` test, reproduced here:
```python
import xarray as xr
import matplotlib.pyplot as plt
import numpy as np
import matplotlib
x = np.arange(start=0, stop=10, step=2)
y = np.arange(start=9, stop=-7, step=-3)
xy = np.dstack(np.meshgrid(x, y))
distance = np.linalg.norm(xy, axis=2)
darray = xr.DataArray(distance, list(zip(('y', 'x'), (y, x))))
darray.plot(levels=7, vmin=4, vmax=8, extend='both')
plt.title('mpl {}'.format(matplotlib.__version__))
```
produces:


","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,196278181
https://github.com/pydata/xarray/pull/1171#issuecomment-269094708,https://api.github.com/repos/pydata/xarray/issues/1171,269094708,MDEyOklzc3VlQ29tbWVudDI2OTA5NDcwOA==,10050469,2016-12-24T18:11:09Z,2016-12-24T18:11:09Z,MEMBER,"@jhamman I planned to do so but I won't come to this in the next couple of days, so if its urgent and you want to do it go ahead! They should be easy fixes","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,196278181
https://github.com/pydata/xarray/pull/1171#issuecomment-267824875,https://api.github.com/repos/pydata/xarray/issues/1171,267824875,MDEyOklzc3VlQ29tbWVudDI2NzgyNDg3NQ==,10050469,2016-12-18T14:40:48Z,2016-12-18T14:40:48Z,MEMBER,... three failing tests. Not too bad!,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,196278181