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/1079#issuecomment-259832229,https://api.github.com/repos/pydata/xarray/issues/1079,259832229,MDEyOklzc3VlQ29tbWVudDI1OTgzMjIyOQ==,1217238,2016-11-10T22:54:15Z,2016-11-10T22:54:15Z,MEMBER,"Yes, thanks! On Thu, Nov 10, 2016 at 2:43 PM, Fabien Maussion notifications@github.com wrote: > ## _@fmaussion_ commented on this pull request. > > In xarray/test/test_plot.py https://github.com/pydata/xarray/pull/1079: > > > @@ -1,3 +1,5 @@ > > +from **future** import division > > Yes OK. shouldn't I do this in a separate PR? I'll do it tomorrow though, > it's getting late in Innsbruck... > > — > You are receiving this because you were mentioned. > Reply to this email directly, view it on GitHub > https://github.com/pydata/xarray/pull/1079, or mute the thread > https://github.com/notifications/unsubscribe-auth/ABKS1vqdXfCSLnXeKwewm2EH6rqzvp1fks5q854MgaJpZM4Ko_0w > . ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,187208913 https://github.com/pydata/xarray/pull/1079#issuecomment-259734708,https://api.github.com/repos/pydata/xarray/issues/1079,259734708,MDEyOklzc3VlQ29tbWVudDI1OTczNDcwOA==,10050469,2016-11-10T16:21:28Z,2016-11-10T16:21:28Z,MEMBER,"I had to modify your code a little bit for this to work, but this is now accepting any axis. Quite a useful function actually! ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,187208913 https://github.com/pydata/xarray/pull/1079#issuecomment-259249333,https://api.github.com/repos/pydata/xarray/issues/1079,259249333,MDEyOklzc3VlQ29tbWVudDI1OTI0OTMzMw==,10050469,2016-11-08T20:25:21Z,2016-11-08T20:26:15Z,MEMBER,"Note that in that case, [multidimensional-coords](https://raw.githubusercontent.com/pydata/xarray/master/doc/examples/multidimensional-coords.rst) and [monthly-means](https://raw.githubusercontent.com/pydata/xarray/master/doc/examples/monthly-means.rst) are already formatted in rst. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,187208913 https://github.com/pydata/xarray/pull/1079#issuecomment-259249543,https://api.github.com/repos/pydata/xarray/issues/1079,259249543,MDEyOklzc3VlQ29tbWVudDI1OTI0OTU0Mw==,1217238,2016-11-08T20:26:08Z,2016-11-08T20:26:08Z,MEMBER,"Right, we used a static ipynb -> rst converter ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,187208913 https://github.com/pydata/xarray/pull/1079#issuecomment-259247304,https://api.github.com/repos/pydata/xarray/issues/1079,259247304,MDEyOklzc3VlQ29tbWVudDI1OTI0NzMwNA==,1217238,2016-11-08T20:16:58Z,2016-11-08T20:16:58Z,MEMBER,"Yes, could certainly run this at doc build time instead of using a notebook. The advantage of the notebook is that it's easier to edit/assemble, and also easier to download and adjust. In an ideal world, I think we would check in a notebook with cleared output and then run it and convert to HTML at doc build time. Looks like that's exactly what [nbsphinx](https://github.com/spatialaudio/nbsphinx) does if anyone wants to take a go at setting that up. Could be a much nicer way to write the docs than RST. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,187208913 https://github.com/pydata/xarray/pull/1079#issuecomment-259240738,https://api.github.com/repos/pydata/xarray/issues/1079,259240738,MDEyOklzc3VlQ29tbWVudDI1OTI0MDczOA==,10050469,2016-11-08T19:51:46Z,2016-11-08T19:51:46Z,MEMBER,"OK. Let's see what the gurus say about this, maybe there is a reason to keep it like this ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,187208913 https://github.com/pydata/xarray/pull/1079#issuecomment-259239692,https://api.github.com/repos/pydata/xarray/issues/1079,259239692,MDEyOklzc3VlQ29tbWVudDI1OTIzOTY5Mg==,1197350,2016-11-08T19:48:01Z,2016-11-08T19:48:01Z,MEMBER,"> is there a reason for this? My laziness / ignorance of the documentation build process. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,187208913 https://github.com/pydata/xarray/pull/1079#issuecomment-259237434,https://api.github.com/repos/pydata/xarray/issues/1079,259237434,MDEyOklzc3VlQ29tbWVudDI1OTIzNzQzNA==,10050469,2016-11-08T19:39:40Z,2016-11-08T19:41:27Z,MEMBER,"@rabernat : couldn't your tutorial also use the ipython directive and run at build time instead of using the parsed literals? I see that the other examples are also static, is there a reason for this? ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,187208913 https://github.com/pydata/xarray/pull/1079#issuecomment-259220758,https://api.github.com/repos/pydata/xarray/issues/1079,259220758,MDEyOklzc3VlQ29tbWVudDI1OTIyMDc1OA==,10050469,2016-11-08T18:36:43Z,2016-11-08T18:36:43Z,MEMBER,"@rabernat thanks for the link! I'll update the docs with a link to your example and with ""multidimensional"" instead of ""irregular"". ","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,187208913 https://github.com/pydata/xarray/pull/1079#issuecomment-259219301,https://api.github.com/repos/pydata/xarray/issues/1079,259219301,MDEyOklzc3VlQ29tbWVudDI1OTIxOTMwMQ==,1197350,2016-11-08T18:31:16Z,2016-11-08T18:31:16Z,MEMBER,"This looks like a really nice PR. There is some intersection with my ""multidimensional coordinates"" tutorial: http://xarray.pydata.org/en/stable/examples/multidimensional-coords.html At the least, we should standardize the terminology in the docs. Are these ""irregular coordinates"" or ""multidimensional coordinates""? I don't particularly care, but we should be consistent. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,187208913 https://github.com/pydata/xarray/pull/1079#issuecomment-259215110,https://api.github.com/repos/pydata/xarray/issues/1079,259215110,MDEyOklzc3VlQ29tbWVudDI1OTIxNTExMA==,10050469,2016-11-08T18:15:45Z,2016-11-08T18:15:45Z,MEMBER,"> Should I remove the if hasattr(ax, 'projection') altogether? Finally I think it's ok to keep it as it is now, since the data above is likely to always be plotted on a map anyways. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,187208913 https://github.com/pydata/xarray/pull/1079#issuecomment-258923845,https://api.github.com/repos/pydata/xarray/issues/1079,258923845,MDEyOklzc3VlQ29tbWVudDI1ODkyMzg0NQ==,10050469,2016-11-07T18:43:24Z,2016-11-07T18:43:24Z,MEMBER,"Actually, you wouldn't like to infer intervals on these coordinates at all, regardless if you are on a map or not. Should I remove the `if hasattr(ax, 'projection')` altogether? ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,187208913 https://github.com/pydata/xarray/pull/1079#issuecomment-258921077,https://api.github.com/repos/pydata/xarray/issues/1079,258921077,MDEyOklzc3VlQ29tbWVudDI1ODkyMTA3Nw==,10050469,2016-11-07T18:33:20Z,2016-11-07T18:33:20Z,MEMBER,"@jhamman @shoyer this is ready for another review (the test failure seems unrelated). @ocefpaf I added a note to the docs @jhamman OK now I get why it clearly doesn't make sense to infer anything in your dataset (plot below). Just out of curiosity: does RASM have a map projection on which it has regular coordinates, too? ![figure_1-1](https://cloud.githubusercontent.com/assets/10050469/20070455/b5d2c16c-a520-11e6-9a85-b5f290671f72.png) ","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,187208913 https://github.com/pydata/xarray/pull/1079#issuecomment-258848096,https://api.github.com/repos/pydata/xarray/issues/1079,258848096,MDEyOklzc3VlQ29tbWVudDI1ODg0ODA5Ng==,2443309,2016-11-07T14:23:35Z,2016-11-07T14:23:35Z,MEMBER,"You can get data on the same grid (different variable, same coords) from the sample data `ds = xr.tutorial.load_dataset('rasm').isel(time=0)`. From there, my example should work. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,187208913 https://github.com/pydata/xarray/pull/1079#issuecomment-258695618,https://api.github.com/repos/pydata/xarray/issues/1079,258695618,MDEyOklzc3VlQ29tbWVudDI1ODY5NTYxOA==,10050469,2016-11-06T17:22:14Z,2016-11-07T13:57:17Z,MEMBER,"After giving this a few more thoughts: 1. if the coordinates are 1D (i.e. the grid is regular in the scipy sense: the coordinates don't have to be evenly spaced), `infer_intervals` should be set to `True` by default. This should make everybody happy (including @jhamman and me), and this will cover a huge majority of the geoscientific grids. 2. if the coordinates are 2D, what xarray was doing until now was wrong. `_infer_interval_breaks` was inferring intervals on the first axis only and ignoring the second, so regardless of whether we were plotting on a projection or not, the plot output was cropped (see example above) So what do we do with this? @jhamman 's suggestion is to set `infer_intervals` to `False`, which is equivalent to saying: ""this plot is going to be a bit wrong but this is not xarray's problem"". I guess that it's fine to do so, but we'd have to be happy with the following: ``` python import numpy as np import matplotlib.pyplot as plt import cartopy.crs as ccrs import xarray as xr lon, lat = np.linspace(-20, 20, 5), np.linspace(0, 30, 4) lon, lat = np.meshgrid(lon, lat) lon += lat/10 lat += lon/10 da = xr.DataArray(np.arange(20).reshape(4, 5), dims=['y', 'x'], coords = {'lat': (('y', 'x'), lat), 'lon': (('y', 'x'), lon)}) ax = plt.subplot(1, 2, 1, projection=ccrs.PlateCarree()) da.plot.pcolormesh('lon', 'lat', ax=ax, transform=ccrs.PlateCarree(), infer_intervals=False) ax.scatter(lon, lat, transform=ccrs.PlateCarree()) ax.coastlines() ax.set_title('2d irreg case - pcolor') ax = plt.subplot(1, 2, 2, projection=ccrs.PlateCarree()) da.plot.contourf('lon', 'lat', ax=ax, transform=ccrs.PlateCarree()) ax.scatter(lon, lat, transform=ccrs.PlateCarree()) ax.coastlines() ax.set_title('2d irreg case - contourf') ``` ![figure_1-3](https://cloud.githubusercontent.com/assets/10050469/20039837/d9d4bec4-a44b-11e6-9450-dbca88ecb56e.png) Note that one line and one column of data disappeared (so that the colorbar range doesn't correspond to what we see) and the coordinates are not understood as being in the cell center. The advantage of this choice are twofold: - it's kind of coherent with how `contourf` would interpret the coordinates (see example above) - if we agree on ""1D = infer per default"" and ""2D = don't infer per default"", we might even get rid of the new keyword altogether. Let's call this option ""Option A"". [edited] I've been playing around with an ""Option B"", which includes making `_infer_interval_breaks` accept an `axis` kwarg. Regardless of the implementation, we could reach the following result: ![figure_1](https://cloud.githubusercontent.com/assets/10050469/20060230/6efd44d6-a4fa-11e6-8327-8f7abb9ff1f3.png) [\edited] This plot is closer to what I think the grid actually represents, but I am biased towards my usage of xarray (gridded geoscientific models). The disadvantages of option B are: - it adds a bit of complexity - if you think about it, the problem of plotting irregular grids is not really an xarray problem. If there was a perfect way to handle an irregular grids without having bounded coordinates, I guess that matplotlib would have a tool for it. I currently tend to go for option A, since option B is a bit awkward and users who have bounded coordinated available somewhere (as suggested by @ocefpaf ) will have to implement their own plotting routine anyway. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,187208913 https://github.com/pydata/xarray/pull/1079#issuecomment-258841318,https://api.github.com/repos/pydata/xarray/issues/1079,258841318,MDEyOklzc3VlQ29tbWVudDI1ODg0MTMxOA==,10050469,2016-11-07T13:55:56Z,2016-11-07T13:55:56Z,MEMBER,"I've come up with a cleaner implementation which doesn't require scipy and produces a very accurate plot: ![figure_1](https://cloud.githubusercontent.com/assets/10050469/20060130/edfe1630-a4f9-11e6-8022-e38d6eb47541.png) I'm going to clean all this later today and update my PR, I think that we can come to something nice. @jhamman : I wonder if the problem you are having in your [example](https://github.com/pydata/xarray/issues/781#issuecomment-191595449) is related to flaoting point issues at the pole. Would you mind sending me the file and the code that produces the plot so that I can have a look at it? ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,187208913 https://github.com/pydata/xarray/pull/1079#issuecomment-258456887,https://api.github.com/repos/pydata/xarray/issues/1079,258456887,MDEyOklzc3VlQ29tbWVudDI1ODQ1Njg4Nw==,1217238,2016-11-04T15:08:34Z,2016-11-04T15:08:34Z,MEMBER,"We definitely ignore cell boundaries -- they don't (yet) have any place in the xarray data model. It would be nice to have a built in ""interval"" data type, along with an `IntervalIndex`, that we could use for storing and doing lookups along interval axes. At one point I was working on this for pandas (see https://github.com/pandas-dev/pandas/issues/7640), but then abandoned my effort when it seemed like it would be too much work to get it finished. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,187208913 https://github.com/pydata/xarray/pull/1079#issuecomment-258388424,https://api.github.com/repos/pydata/xarray/issues/1079,258388424,MDEyOklzc3VlQ29tbWVudDI1ODM4ODQyNA==,10050469,2016-11-04T10:03:04Z,2016-11-04T10:03:04Z,MEMBER,"> In the old Matlab day we had horrible hacks to get pcolor to work properly pcolormesh and imshow are indeed very consistent in xarray: ``` python import numpy as np import matplotlib.pyplot as plt import cartopy.crs as ccrs import xarray as xr da = xr.DataArray(np.arange(20).reshape(4, 5), dims=['lat', 'lon'], coords = {'lat': np.linspace(0, 30, 4), 'lon': np.linspace(-20, 20, 5)}) f = plt.figure(figsize=(5, 8)) ax = plt.subplot(3, 1, 1, projection=ccrs.PlateCarree()) da.plot.imshow(ax=ax, transform=ccrs.PlateCarree()) lon, lat = np.meshgrid(da.lon.values, da.lat.values) ax.scatter(lon, lat, transform=ccrs.PlateCarree()) ax.coastlines() ax.set_title('imshow') ax = plt.subplot(3, 1, 2, projection=ccrs.PlateCarree()) da.plot.pcolormesh(ax=ax, transform=ccrs.PlateCarree()) ax.scatter(lon, lat, transform=ccrs.PlateCarree()) ax.coastlines() ax.set_title('pcolormesh') ax = plt.subplot(3, 1, 3, projection=ccrs.PlateCarree()) da.plot.pcolormesh(ax=ax, transform=ccrs.PlateCarree(), infer_intervals=False) ax.scatter(lon, lat, transform=ccrs.PlateCarree()) ax.coastlines() ax.set_title('pcolormesh - no intervals') ``` ![figure_1](https://cloud.githubusercontent.com/assets/10050469/20001746/d6bfb3c6-a27d-11e6-9e35-82e88a2aec24.png) In most cases setting `infer_intervals=False` won't be a good idea, but maybe for some exotic projections (at the pole in @jhamman example) it might be easier this way (albeit a bit ""wrong""). ","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,187208913 https://github.com/pydata/xarray/pull/1079#issuecomment-258380050,https://api.github.com/repos/pydata/xarray/issues/1079,258380050,MDEyOklzc3VlQ29tbWVudDI1ODM4MDA1MA==,10050469,2016-11-04T09:22:01Z,2016-11-04T09:22:01Z,MEMBER,"> Is infer_intervals creating coordinate bounds for plotting? It looks like it. Yes, it is a special case for pcolormesh though > What about when we do have cell boundaries in the dataset? Currently the entire xarray workflow is built upon the implicit assumption that the coordinates are always at the grid-point center ( @shoyer correct me if I'm wrong). I'm not sure if the additional complexity added by cell boundaries is on the xarray devs priority list... ","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,187208913 https://github.com/pydata/xarray/pull/1079#issuecomment-258318659,https://api.github.com/repos/pydata/xarray/issues/1079,258318659,MDEyOklzc3VlQ29tbWVudDI1ODMxODY1OQ==,1217238,2016-11-04T01:01:23Z,2016-11-04T01:01:23Z,MEMBER,"I would call this just `infer_intervals`. `breaks` in the helper function name is referring to an implementation detail of how we store the intervals (by using breaks). ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,187208913