You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importxarrayasxrimportnumpyasnpairtemps=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 meair.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:
/usr/local/Miniconda3-envs/envs/2019/envs/iacpy3_2019/lib/python3.7/site-packages/xarray/plot/utils.pyin_process_cmap_cbar_kwargs(func, kwargs, data)
683# colors is only valid when levels is supplied or the plot is of type684# contour or contourf-->685ifcolorsand (('contour'notinfunc.__name__) and (notlevels)):
686raiseValueError("Can only specify colors with contour or levels")
687ValueError: Thetruthvalueofanarraywithmorethanoneelementisambiguous. Usea.any() ora.all()
I just found out - the error actually comes from using a numpy array to the define the levels (and (not levels)) and not from using colors. So it is in a way a user error. However, I suppose it would be good to support numpy arrays to pass levels?
MCVE Code Sample
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:
Instead I use the following, which works:
Output of
xr.show_versions()
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
The text was updated successfully, but these errors were encountered: