home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 532165408

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
532165408 MDU6SXNzdWU1MzIxNjU0MDg= 3590 cmap.set_under() does not work as expected 3958036 closed 0     5 2019-12-03T18:04:07Z 2020-02-24T20:20:07Z 2020-02-24T20:20:07Z CONTRIBUTOR      

When using matplotlib, the set_under() method can be used to set values below the range of a colormap to a certain color, for example ``` import matplotlib from matplotlib import pyplot import numpy

dat = numpy.linspace(0, 1)[numpy.newaxis, :]*numpy.linspace(0, 1)[:, numpy.newaxis]

cmap = matplotlib.cm.viridis

cmap.set_under('w')

pyplot.contourf(dat, vmin=.3, cmap=cmap) pyplot.colorbar() pyplot.show() ``` produces

while uncommenting the cmap.set_under() call produces

However, using xarray to do the same thing, ``` import matplotlib from matplotlib import pyplot from xarray import DataArray import numpy

da = DataArray(numpy.linspace(0, 1)[numpy.newaxis, :]*numpy.linspace(0, 1)[:, numpy.newaxis])

cmap = matplotlib.cm.viridis cmap.set_under('w')

da.plot.contourf(vmin=.3, cmap=cmap) pyplot.show() `` produces ![xarray](https://user-images.githubusercontent.com/3958036/70076465-bc174080-15f6-11ea-9f59-37f20569cf6e.png) where it seems the call tocmap.set_under('w')` had no effect. Expected behaviour would be output like the second plot.

Output of xr.show_versions()

``` In [2]: xarray.show_versions() INSTALLED VERSIONS ------------------ commit: None python: 3.6.9 (default, Nov 7 2019, 10:44:02) [GCC 8.3.0] python-bits: 64 OS: Linux OS-release: 5.0.0-37-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_GB.UTF-8 LOCALE: en_GB.UTF-8 libhdf5: 1.10.0 libnetcdf: 4.6.0 xarray: 0.14.1 pandas: 0.24.2 numpy: 1.16.3 scipy: 1.2.1 netCDF4: 1.3.1 pydap: None h5netcdf: None h5py: 2.9.0 Nio: None zarr: None cftime: None nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: 2.1.0 distributed: None matplotlib: 3.1.1 cartopy: None seaborn: None numbagg: None setuptools: 41.0.1 pip: 19.3.1 conda: None pytest: 4.4.1 IPython: 7.6.1 sphinx: None ```
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/3590/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

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