home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 258388424

This data as json

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-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') ```

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
Powered by Datasette · Queries took 0.971ms · About: xarray-datasette