Skip to content

Transform not working with xlim / ylim and col_wrap  #8562

@sarahclaude

Description

@sarahclaude

What happened?

I get back the wrong projections when passing transform with col_wrap = 2 while plotting a facetgrid (first picture).
I also get empty subplots when using transform = ccrs.PlateCarrree with a defined xlim and ylim (second picture).

image
image

What did you expect to happen?

image

Minimal Complete Verifiable Example

import xarray as xr

url = 'https://pavics.ouranos.ca//twitcher/ows/proxy/thredds/dodsC/birdhouse/disk2/cccs_portal/indices/Final/BCCAQv2_CMIP6/tx_max/YS/ssp585/ensemble_percentiles/tx_max_ann_BCCAQ2v2+ANUSPLIN300_historical+ssp585_1950-2100_30ymean_percentiles.nc'

opened = xr.open_dataset(url, decode_timedelta=False)
ds_space = opened[['tx_max_p50']].isel(time=[0, 1, 2]).sel(lat=slice(40,65), lon=slice(-90,-55))

#transform with col_wrap
ds_space['tx_max_p50'].plot(**{"x": "lon", "y": "lat", "col": "time", 'col_wrap':2},
                            subplot_kws={"projection": ccrs.LambertConformal()},
                            transform = ccrs.PlateCarree()
                           )

#transform and xlim/ylim
ds_space['tx_max_p50'].plot(**{"x": "lon", "y": "lat", "col": "time", 
"xlim": [-70, -75], "ylim": [45, 50]},
                            subplot_kws={"projection": ccrs.LambertConformal()},
                            transform = ccrs.PlateCarree()
                           )

MVCE confirmation

  • Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
  • Complete example — the example is self-contained, including all data and the text of any traceback.
  • Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
  • New issue — a search of GitHub Issues suggests this is not a duplicate.
  • Recent environment — the issue occurs with the latest version of xarray and its dependencies.

Relevant log output

No response

Anything else we need to know?

No response

Environment

Details commit: None python: 3.11.0 | packaged by conda-forge | (main, Jan 14 2023, 12:27:40) [GCC 11.3.0] python-bits: 64 OS: Linux OS-release: 6.2.0-39-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: fr_CA.UTF-8 LOCALE: ('fr_CA', 'UTF-8') libhdf5: 1.14.0 libnetcdf: 4.9.2

xarray: 2023.10.1
pandas: 2.0.2
numpy: 1.24.3
scipy: 1.10.1
netCDF4: 1.6.4
pydap: None
h5netcdf: None
h5py: 3.8.0
Nio: None
zarr: 2.15.0
cftime: 1.6.2
nc_time_axis: None
PseudoNetCDF: None
iris: None
bottleneck: 1.3.7
dask: 2023.6.0
distributed: 2023.6.0
matplotlib: 3.7.1
cartopy: 0.21.1
seaborn: 0.12.2
numbagg: None
fsspec: 2023.6.0
cupy: None
pint: 0.22
sparse: None
flox: None
numpy_groupies: None
setuptools: 67.7.2
pip: 23.1.2
conda: None
pytest: 7.3.2
mypy: None
IPython: 8.14.0
sphinx: 7.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds triageIssue that has not been reviewed by xarray team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions