home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 663769801

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
663769801 MDU6SXNzdWU2NjM3Njk4MDE= 4247 plot/utils get_axis cannot use subplot_kws with existing ax 18679148 closed 0     2 2020-07-22T13:38:04Z 2020-07-22T14:59:16Z 2020-07-22T14:59:16Z NONE      

I get the following error when I move from xarray 0.15.1 to 0.16.0 "cannot use subplot_kws with existing ax". I don't really understand why this error is raised, but as far as I use it (see below), I feel I need to use both ax and subplot_kws. Please find below a minimum case: ```python import numpy as np import pandas as pd import xarray as xr import matplotlib.pyplot as plt import cartopy.crs as ccrs

x = np.arange(0,3) y = np.arange(0,5) z = np.arange(0,2) xx, yy, zz = np.meshgrid(x, y, z)

lat = 40 + xx0.1 + yy1 lon = 5 + xx1 + yy0.1 + zz5 data3 = xx + yy + 5zz data4 = np.stack([data3, data32, data34, data3*8])

ds = xr.Dataset({'data': (['time','x','y','z'], data4)}, coords={'time': pd.date_range("2020-01-01", periods=4), 'lon': (['x','y','z'], lon), 'lat': (['x','y','z'], lat)} ) ```

So I have lon/lat maps with two swaths (z-dimension). I want to plot both swaths on the same map, and as function of time ```python plt.figure() for ss in z: ds.data.isel(time=0, z=ss).plot(x='lon', y='lat', add_colorbar=False, vmin=0, vmax=12)

plt.figure() g = ds.data.isel(z=0).plot(x='lon', y='lat', col='time') for cc, ax in enumerate(g.axes.flat): for ss in z: ds.data.isel(time=cc, z=ss).plot(x='lon', y='lat', add_colorbar=False, vmin=0, vmax=50, ax=ax) ```

All is relatively fine, the issue is when I want to project it on a map using Cartopy: Still fine with only one map: python plt.figure() for ss in z: ds.data.isel(time=0, z=ss).plot(x='lon', y='lat', add_colorbar=False, vmin=0, vmax=12, transform=ccrs.PlateCarree(), subplot_kws={'projection': ccrs.Mercator()})

but the "ValueError: cannot use subplot_kws with existing ax" is raised when I try with the facets plot: python plt.figure() g = ds.data.isel(z=0).plot(x='lon', y='lat', col='time', transform=ccrs.PlateCarree(), subplot_kws={'projection': ccrs.Mercator()}) for cc, ax in enumerate(g.axes.flat): for ss in z: ds.data.isel(time=cc, z=ss).plot(x='lon', y='lat', add_colorbar=False, vmin=0, vmax=50, ax=ax, transform=ccrs.PlateCarree(), subplot_kws={'projection': ccrs.Mercator()})

On a side note, I don't understand why I am loosing one pixel per row and column using the cartopy projection.

Output of <tt>xr.show_versions()</tt> INSTALLED VERSIONS ------------------ commit: None python: 3.7.6 (default, Jan 8 2020, 13:42:34) [Clang 4.0.1 (tags/RELEASE_401/final)] python-bits: 64 OS: Darwin OS-release: 19.5.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: en_GB.UTF-8 LOCALE: en_GB.UTF-8 libhdf5: 1.10.4 libnetcdf: 4.6.1 xarray: 0.16.0 pandas: 1.0.1 numpy: 1.18.1 scipy: 1.4.1 netCDF4: 1.4.2 pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.0.4.2 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: 2.10.1 distributed: 2.10.0 matplotlib: 3.1.3 cartopy: 0.17.0 seaborn: None numbagg: None pint: None setuptools: 45.2.0.post20200210 pip: 20.0.2 conda: None pytest: None IPython: 7.12.0 sphinx: None
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/4247/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed 13221727 issue

Links from other tables

  • 0 rows from issues_id in issues_labels
  • 2 rows from issue in issue_comments
Powered by Datasette · Queries took 1.034ms · About: xarray-datasette