home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 490229690

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
490229690 MDU6SXNzdWU0OTAyMjk2OTA= 3284 specifying list of colors does not work for me 10194086 closed 0     1 2019-09-06T09:36:08Z 2019-09-09T18:31:16Z 2019-09-09T18:31:16Z MEMBER      

MCVE Code Sample

```python import xarray as xr import numpy as np

airtemps = xr.tutorial.load_dataset('air_temperature')

air = airtemps.air.isel(time=0)

levels = np.arange(225, 301, 25)

colors = ['#ffffb2', '#fecc5c', '#fd8d3c', '#e31a1c']

this does not work for me

air.plot.pcolormesh(levels=levels, colors=colors)

```

Expected Output

Should create a plot with the specified colors. According to the the docstring this should work. Or maybe I am doing something wrong here?

Problem Description

Instead I get the following error: ```python /usr/local/Miniconda3-envs/envs/2019/envs/iacpy3_2019/lib/python3.7/site-packages/xarray/plot/utils.py in _process_cmap_cbar_kwargs(func, kwargs, data) 683 # colors is only valid when levels is supplied or the plot is of type 684 # contour or contourf --> 685 if colors and (('contour' not in func.name) and (not levels)): 686 raise ValueError("Can only specify colors with contour or levels") 687

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() ```

Instead I use the following, which works:

python air.plot.pcolormesh(levels=levels, cmap=colors)

Output of xr.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.7.1 | packaged by conda-forge | (default, Feb 18 2019, 01:42:00) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 4.12.14-lp151.28.13-default machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_GB.UTF-8 LOCALE: en_US.UTF-8 libhdf5: 1.10.4 libnetcdf: 4.6.2 xarray: 0.12.1 pandas: 0.24.2 numpy: 1.16.2 scipy: 1.2.1 netCDF4: 1.5.0.1 pydap: installed h5netcdf: 0.7.1 h5py: 2.9.0 Nio: None zarr: 2.3.1 cftime: 1.0.3.4 nc_time_axis: 1.2.0 PseudonetCDF: None rasterio: 1.0.22 cfgrib: 0.9.7 iris: 2.2.0 bottleneck: 1.2.1 dask: 1.1.5 distributed: 1.26.1 matplotlib: 3.0.3 cartopy: 0.17.0 seaborn: 0.9.0 setuptools: 41.0.0 pip: 19.0.3 conda: None pytest: 4.4.0 IPython: 7.4.0 sphinx: 2.0.1
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/3284/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
  • 1 row from issue in issue_comments
Powered by Datasette · Queries took 0.565ms · About: xarray-datasette