home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 559217441

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
559217441 MDU6SXNzdWU1NTkyMTc0NDE= 3744 Contour with vmin/ vmax differs from matplotlib 10194086 open 0     0 2020-02-03T17:11:24Z 2021-07-04T02:03:02Z   MEMBER      

MCVE Code Sample

```python import numpy as np import xarray as xr import matplotlib as mpl import matplotlib.pyplot as plt

data = xr.DataArray(np.arange(24).reshape(4, 6))

data.plot.contour(vmax=10, add_colorbar=True) ```

Expected Output

python h = plt.contour(data.values, vmax=10) plt.colorbar(h)

Problem Description

A contour(vmax=vmax) plot differs between xarray and matplotlib. I think the problem is here:

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

xarray calculates the levels from vmax while matplotlib (probably) calculates the levels from data.max() and uses vmax only for the norm. For contourf and pcolormesh this is not so relevant as the capped values are then drawn with the over color. However, there may also be a good reason for this behavior.

Output of xr.show_versions()

INSTALLED VERSIONS ------------------ commit: 4c96d53e6caa78d56b785f4edee49bbd4037a82f python: 3.7.6 | packaged by conda-forge | (default, Jan 7 2020, 22:33:48) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 4.12.14-lp151.28.36-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.5 libnetcdf: 4.6.2 xarray: 999 (master) pandas: 0.25.3 numpy: 1.17.3 scipy: 1.4.1 netCDF4: 1.5.1.2 pydap: installed h5netcdf: 0.7.4 h5py: 2.10.0 Nio: 1.5.5 zarr: 2.4.0 cftime: 1.0.4.2 nc_time_axis: 1.2.0 PseudoNetCDF: installed rasterio: 1.1.0 cfgrib: 0.9.7.6 iris: 2.2.0 bottleneck: 1.3.1 dask: 2.9.2 distributed: 2.9.2 matplotlib: 3.1.2 cartopy: 0.17.0 seaborn: 0.9.0 numbagg: installed setuptools: 45.0.0.post20200113 pip: 19.3.1 conda: None pytest: 5.3.3 IPython: 7.11.1 sphinx: None
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/3744/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
    13221727 issue

Links from other tables

  • 1 row from issues_id in issues_labels
  • 0 rows from issue in issue_comments
Powered by Datasette · Queries took 0.564ms · About: xarray-datasette