home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 558140877

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
558140877 MDU6SXNzdWU1NTgxNDA4Nzc= 3735 Contour plot with norm and int or no levels fails. 1186928 closed 0     1 2020-01-31T13:45:07Z 2020-05-12T22:47:51Z 2020-05-12T22:47:51Z CONTRIBUTOR      

MCVE Code Sample

python import numpy as np import xarray as xr import matplotlib as mpl data = xr.DataArray(np.arange(24).reshape(4, 6)) data.plot.contour(norm=mpl.colors.Normalize(vmin=5, vmax=10))

Yields:

python Traceback (most recent call last): File "<stdin>", line 1, in <module> File ".../xarray/xarray/plot/plot.py", line 816, in plotmethod return newplotfunc(**allargs) File ".../xarray/xarray/plot/plot.py", line 694, in newplotfunc cmap_params, cbar_kwargs = _process_cmap_cbar_kwargs( File ".../xarray/xarray/plot/utils.py", line 772, in _process_cmap_cbar_kwargs cmap_params = _determine_cmap_params(**cmap_kwargs) File ".../xarray/xarray/plot/utils.py", line 278, in _determine_cmap_params cmap, newnorm = _build_discrete_cmap(cmap, levels, extend, filled) File ".../xarray/xarray/plot/utils.py", line 94, in _build_discrete_cmap n_colors = len(levels) + ext_n - 1

Expected Output

A plot.

Problem Description

I think this has to do with:

https://github.com/pydata/xarray/blob/95e4f6c7a636878c94b892ee8d49866823d0748f/xarray/plot/utils.py#L744

And the line where the code fails:

https://github.com/pydata/xarray/blob/95e4f6c7a636878c94b892ee8d49866823d0748f/xarray/plot/utils.py#L94

There should be an easy fix, I think.

Output of xr.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.8.1 (default, Jan 22 2020, 06:38:00) [GCC 9.2.0] python-bits: 64 OS: Linux OS-release: 4.19.98-1-MANJARO machine: x86_64 processor: byteorder: little LC_ALL: None LANG: fr_CH.utf8 LOCALE: fr_CH.UTF-8 libhdf5: 1.10.5 libnetcdf: 4.7.3 xarray: 0.14.1 pandas: 0.25.3 numpy: 1.18.1 scipy: 1.4.1 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: 1.1.1 cfgrib: None iris: None bottleneck: None dask: 2.8.0 distributed: None matplotlib: 3.1.2 cartopy: 0.17.0 seaborn: None numbagg: None setuptools: 44.0.0 pip: 19.3 conda: None pytest: 5.3.4 IPython: 7.11.1 sphinx: 2.2.1
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/3735/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
  • 1 row from issue in issue_comments
Powered by Datasette · Queries took 1.668ms · About: xarray-datasette