Skip to content

Wrong facet plots when all 2D arrays have one value only #3734

@malmans2

Description

@malmans2

MCVE Code Sample

import xarray as xr
import numpy as np
# Create DataArray
da = xr.DataArray(np.zeros((10, 10, 4)))
# Default plot
# Wrong: all of them should be 0.
da.plot(col='dim_2')
<xarray.plot.facetgrid.FacetGrid at 0x7f511815f3d0>

output_2_1

Expected Output

# Providing colorbar limits
# Correct.
da.plot(col='dim_2', vmin=-.1, vmax=.1)
<xarray.plot.facetgrid.FacetGrid at 0x7f50ef14bf70>

output_3_1

Problem Description

If I simply use plot triggering FacetGrid to show 2D arrays which all have the same value (zero in the example above), all plots with exception of the last one are wrong. However, if I specify vmin and vmax using the same limits of the default plot, all plots are correct.

Output of xr.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 3.8.1 | packaged by conda-forge | (default, Jan 29 2020, 14:55:04) 
[GCC 7.3.0]
python-bits: 64
OS: Linux
OS-release: 4.4.0-133-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
libhdf5: 1.10.5
libnetcdf: 4.7.3

xarray: 0.14.1
pandas: 1.0.0
numpy: 1.17.5
scipy: None
netCDF4: 1.5.3
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: 1.3.1
dask: 2.10.1
distributed: 2.10.0
matplotlib: 3.1.2
cartopy: None
seaborn: None
numbagg: None
setuptools: 45.1.0.post20200119
pip: 20.0.2
conda: None
pytest: None
IPython: 7.11.1
sphinx: None

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions