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/657#issuecomment-226274164,https://api.github.com/repos/pydata/xarray/issues/657,226274164,MDEyOklzc3VlQ29tbWVudDIyNjI3NDE2NA==,10050469,2016-06-15T18:17:51Z,2016-06-15T18:17:51Z,MEMBER,"OK, on the current master and with a cartopy installed from conda-forge I am not able to reproduce the problem any more: ``` imshow xray: 3.30 s pcolormesh xray: 13.13 s pcolormesh cartopy: 12.85 s ``` I don't really understand what happened in between... The factor 4 between `imshow` and `pcolormesh` remains, but at least the show-killer 30sec plotting time I had before is gone. I'm closing this now, and this will remain a mystery. (note: on my laptop I'm getting faster plotting results in a virtualenv configured with `pip install` than with pandas...) ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,117002929 https://github.com/pydata/xarray/issues/657#issuecomment-170220499,https://api.github.com/repos/pydata/xarray/issues/657,170220499,MDEyOklzc3VlQ29tbWVudDE3MDIyMDQ5OQ==,10050469,2016-01-09T10:06:44Z,2016-01-09T10:06:44Z,MEMBER,"I had little time to spend on this lately but I'll try to get back to it in the next days. Any idea on where it could come from? I found it quite hard to debug because of the many decorators... From the profiling and the number of function calls above there seems to be something quite big happening in between xray and cartopy. Could it be something as trivial as a double function call or something? ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,117002929 https://github.com/pydata/xarray/issues/657#issuecomment-157828150,https://api.github.com/repos/pydata/xarray/issues/657,157828150,MDEyOklzc3VlQ29tbWVudDE1NzgyODE1MA==,10050469,2015-11-18T19:19:32Z,2015-11-18T19:19:32Z,MEMBER,"See the number of calls: faster.txt: 4099953 function calls (4093947 primitive calls) in 14.571 seconds slower.txt: 10316809 function calls (10303964 primitive calls) in 34.330 seconds ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,117002929 https://github.com/pydata/xarray/issues/657#issuecomment-157779612,https://api.github.com/repos/pydata/xarray/issues/657,157779612,MDEyOklzc3VlQ29tbWVudDE1Nzc3OTYxMg==,10050469,2015-11-18T17:04:21Z,2015-11-18T17:04:21Z,MEMBER,"Changing the input to `np.ma.asarray(l1 + l2)` did not change anything as far as I can see... ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,117002929 https://github.com/pydata/xarray/issues/657#issuecomment-157768356,https://api.github.com/repos/pydata/xarray/issues/657,157768356,MDEyOklzc3VlQ29tbWVudDE1Nzc2ODM1Ng==,10050469,2015-11-18T16:28:28Z,2015-11-18T16:28:28Z,MEMBER,"Was someone able to reproduce this or is it just me? ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,117002929 https://github.com/pydata/xarray/issues/657#issuecomment-157642290,https://api.github.com/repos/pydata/xarray/issues/657,157642290,MDEyOklzc3VlQ29tbWVudDE1NzY0MjI5MA==,10050469,2015-11-18T08:24:23Z,2015-11-18T08:24:45Z,MEMBER,"Thanks @pelson ! So now this is when it becomes funny: I've been able to make three similar plots using xray's imshow, pcolormesh and cartopy's pcolormesh. Xray's pcolormesh takes twice the time as cartopy's: ``` python import matplotlib.pyplot as plt from matplotlib.colors import Normalize import xray import numpy as np import cartopy.crs as ccrs import time nlats, nlons = (241, 480) lats = np.linspace(90, -90, nlats) lons = np.linspace(0, 360-0.75, nlons) l1, l2 = np.meshgrid(lons, lats) data = xray.DataArray(l1 + l2, [('latitude', lats), ('longitude', lons)]) cmap = plt.get_cmap('viridis') norm = Normalize(vmin=0, vmax=data.max().values) start_time = time.time() fig = plt.figure() ax = plt.axes(projection=ccrs.Robinson()) data.plot.imshow(ax=ax, transform=ccrs.PlateCarree(), add_colorbar=False, cmap=cmap, vmin=0) ax.coastlines() plt.savefig('imshow_xray.png') print(""imshow xray: {:.2f} s"".format(time.time() - start_time)) start_time = time.time() fig = plt.figure() ax = plt.axes(projection=ccrs.Robinson()) data.plot.pcolormesh(ax=ax, transform=ccrs.PlateCarree(), add_colorbar=False, cmap=cmap, vmin=0) ax.coastlines() plt.savefig('pcolormesh_xray.png') print(""pcolormesh xray: {:.2f} s"".format(time.time() - start_time)) start_time = time.time() fig = plt.figure() ax = plt.axes(projection=ccrs.Robinson()) ax.pcolormesh(lons, lats, l1 + l2, transform=ccrs.PlateCarree(), cmap=cmap, norm=norm) ax.coastlines() plt.savefig('pcolormesh_cartopy.png') print(""pcolormesh cartopy: {:.2f} s"".format(time.time() - start_time)) ``` imshow xray: 3.06 s pcolormesh xray: 27.50 s pcolormesh cartopy: 12.14 s ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,117002929 https://github.com/pydata/xarray/issues/657#issuecomment-157413923,https://api.github.com/repos/pydata/xarray/issues/657,157413923,MDEyOklzc3VlQ29tbWVudDE1NzQxMzkyMw==,10050469,2015-11-17T16:02:10Z,2015-11-17T16:02:10Z,MEMBER,"Hi again, I've made a self-contained example below. I have no clue about how cartopy works (blind xray user, sorry :-() and was not able to remove the dependency to xray without getting different plots for imshow() and pcolormesh()... If one of the xray gurus could help me to remove the xray part of the code I could open an issue in cartopy. I wonder if the problem comes from the fact that ERA-Interim lons are spanning 0-360? ``` python import matplotlib.pyplot as plt import xray import numpy as np import cartopy.crs as ccrs import time nlats, nlons = (241, 480) lats = np.linspace(90, -90, nlats) lons = np.linspace(0, 360-0.75, nlons) l1, l2 = np.meshgrid(lons, lats) data = xray.DataArray(l1 + l2, [('latitude', lats), ('longitude', lons)]) start_time = time.time() fig = plt.figure() ax = plt.axes(projection=ccrs.Robinson()) data.plot.imshow(ax=ax, transform=ccrs.PlateCarree()) ax.coastlines() plt.savefig('imshow.png') print(""imshow: {:.2f} s"".format(time.time() - start_time)) start_time = time.time() fig = plt.figure() ax = plt.axes(projection=ccrs.Robinson()) data.plot.pcolormesh(ax=ax, transform=ccrs.PlateCarree()) ax.coastlines() plt.savefig('pcolormesh.png') print(""pcolormesh: {:.2f} s"".format(time.time() - start_time)) ``` imshow: 3.09 s pcolormesh: 27.53 s ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,117002929 https://github.com/pydata/xarray/issues/657#issuecomment-156991224,https://api.github.com/repos/pydata/xarray/issues/657,156991224,MDEyOklzc3VlQ29tbWVudDE1Njk5MTIyNA==,10050469,2015-11-16T10:55:09Z,2015-11-16T10:55:09Z,MEMBER,"I guess it's OK to leave it as is, as long as the performance loss is documented. I like the automatic `plot()` function because it hides the boring mpl internals to my students and (until now) always did what I expected it to do. 30 seconds to generate a plot in a Notebook is definitely a fun killer. Maybe I should still upgrade to 0.6.1 and explain to my students that they should use `imshow()` instead of `plot()`. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,117002929 https://github.com/pydata/xarray/issues/657#issuecomment-156851221,https://api.github.com/repos/pydata/xarray/issues/657,156851221,MDEyOklzc3VlQ29tbWVudDE1Njg1MTIyMQ==,10050469,2015-11-15T20:33:24Z,2015-11-15T20:33:24Z,MEMBER,"If I remove the projection stuff `imshow` and `pcolormesh` are equally fast. Both functions must handle the projection differently, somehow? ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,117002929 https://github.com/pydata/xarray/issues/657#issuecomment-156849447,https://api.github.com/repos/pydata/xarray/issues/657,156849447,MDEyOklzc3VlQ29tbWVudDE1Njg0OTQ0Nw==,10050469,2015-11-15T20:13:46Z,2015-11-15T20:13:46Z,MEMBER,"Thanks for the quick answer. changing to `imshow` indeed reduced the execution time back to normal. I wouldn't expect a factor 10 between `imshow` and `pcolormesh`, though... ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,117002929