Skip to content

Contourf does not add cyclic point #1402

@mickaellalande

Description

@mickaellalande

Description

For non-cyclic data, contourf does not plot continuous data automatically. When there is no problem with pcolormesh. See example below for contourf:
contourf_add_cycle

Data: snc_LImon_IPSL-CM6A-LR_historical_r1i1p1f1_gr_185001.zip

This is pretty inconvenient, to add the cyclic point "by hand" previously to do a plot with from cartopy.util import add_cyclic_point. It would be nice to have an option directly when we plot or to automatically do it when making a contourf.

Code to reproduce

import xarray as xr
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER

plt.figure(figsize=(10,4))
ax = plt.axes(projection=ccrs.PlateCarree())
da.plot.contourf(ax=ax, transform=ccrs.PlateCarree())
ax.coastlines()
ax.set_global()
gl = ax.gridlines(crs=ccrs.PlateCarree(), draw_labels=True, linewidth=0.7, color='gray', alpha=0.5, linestyle='--')
gl.xlabels_top = False
gl.ylabels_right = False
gl.xformatter = LONGITUDE_FORMATTER
gl.yformatter = LATITUDE_FORMATTER

Thanks in advance to consider this. I hope it is not already a topic that was already treated.

Full environment definition

Operating system

Debian 10

Cartopy version

cartopy 0.17.0 py37hbb7e04d_1

conda list

# packages in environment at /home/mlalande/miniconda3:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main  
asn1crypto                1.2.0                    py37_0  
atomicwrites              1.3.0                    pypi_0    pypi
attrs                     19.3.0                     py_0  
backcall                  0.1.0                    py37_0  
blas                      1.0                         mkl  
bleach                    3.1.0                    py37_0  
bokeh                     1.4.0                    py37_0  
bzip2                     1.0.8                h7b6447c_0  
ca-certificates           2019.10.16                    0  
cartopy                   0.17.0           py37hbb7e04d_1  
certifi                   2019.9.11                py37_0  
cffi                      1.13.0           py37h2e261b9_0  
cftime                    1.0.3.4         py37hdd07704_1001  
chardet                   3.0.4                 py37_1003  
click                     7.0                      py37_0  
cloudpickle               1.2.2                      py_0  
conda                     4.7.12                   py37_0  
conda-package-handling    1.6.0            py37h7b6447c_0  
cryptography              2.8              py37h1ba5d50_0  
curl                      7.65.3               hbc83047_0  
cycler                    0.10.0                   py37_0  
cytoolz                   0.10.1           py37h7b6447c_0  
dask                      2.8.0                      py_1  
dask-core                 2.8.0                      py_0  
dbus                      1.13.12              h746ee38_0  
decorator                 4.4.0                    py37_1  
defusedxml                0.6.0                      py_0  
distributed               2.8.0                      py_1  
entrypoints               0.3                      py37_0  
esmf                      8.0.0                ha4864fb_1    conda-forge
esmpy                     8.0.0            py37h5ca1d4c_0    conda-forge
expat                     2.2.6                he6710b0_0  
fontconfig                2.13.0               h9420a91_0  
freetype                  2.9.1                h8a8886c_1  
fsspec                    0.6.0                      py_0  
geos                      3.7.1                he6710b0_0  
glib                      2.56.2               hd408876_0  
gmp                       6.1.2                h6c8ec71_1  
gst-plugins-base          1.14.0               hbbd80ab_1  
gstreamer                 1.14.0               hb453b48_1  
hdf4                      4.2.13               h3ca952b_2  
hdf5                      1.10.5          nompi_h3c11f04_1104    conda-forge
heapdict                  1.0.1                      py_0  
holoviews                 1.12.6                     py_0    pyviz
icu                       58.2                 h9c2bf20_1  
idna                      2.8                      py37_0  
importlib_metadata        0.23                     py37_0  
intel-openmp              2019.4                      243  
ipykernel                 5.1.2            py37h39e3cac_0  
ipython                   7.8.0            py37h39e3cac_0  
ipython_genutils          0.2.0                    py37_0  
ipywidgets                7.5.1                      py_0  
jedi                      0.15.1                   py37_0  
jinja2                    2.10.3                     py_0  
jpeg                      9c                h14c3975_1001    conda-forge
jsonschema                3.1.1                    py37_0  
jupyter                   1.0.0                    py37_7  
jupyter_client            5.3.4                    py37_0  
jupyter_console           6.0.0                    py37_0  
jupyter_core              4.6.0                    py37_0  
kiwisolver                1.1.0            py37he6710b0_0  
krb5                      1.16.1               h173b8e3_7  
libcurl                   7.65.3               h20c2e04_0  
libedit                   3.1.20181209         hc058e9b_0  
libffi                    3.2.1                hd88cf55_4  
libgcc-ng                 9.1.0                hdf63c60_0  
libgfortran-ng            7.3.0                hdf63c60_0  
libnetcdf                 4.7.1           nompi_h94020b1_101    conda-forge
libpng                    1.6.37               hbc83047_0  
libsodium                 1.0.16               h1bed415_0  
libssh2                   1.8.2                h1ba5d50_0  
libstdcxx-ng              9.1.0                hdf63c60_0  
libtiff                   4.0.10               h2733197_2  
libuuid                   1.0.3                h1bed415_2  
libxcb                    1.13                 h1bed415_1  
libxml2                   2.9.9                hea5a465_1  
libxslt                   1.1.33               h7d1a2b0_0  
locket                    0.2.0                    py37_1  
lxml                      4.4.1            py37hefd8a0e_0  
markdown                  3.1.1                    py37_0  
markupsafe                1.1.1            py37h7b6447c_0  
matplotlib                3.1.1            py37h5429711_0  
mistune                   0.8.4            py37h7b6447c_0  
mkl                       2019.4                      243  
mkl-service               2.3.0            py37he904b0f_0  
mkl_fft                   1.0.14           py37ha843d7b_0  
mkl_random                1.1.0            py37hd6b4f25_0  
more-itertools            7.2.0                    py37_0  
mpi                       1.0                       mpich    conda-forge
mpich                     3.3.2                hc856adb_0    conda-forge
msgpack-python            0.6.1            py37hfd86e86_1  
nbconvert                 5.6.0                    py37_1  
nbformat                  4.4.0                    py37_0  
ncurses                   6.1                  he6710b0_1  
netcdf-fortran            4.4.5             h55403cb_1003    conda-forge
netcdf4                   1.5.3            py37hf3213d6_0    conda-forge
notebook                  6.0.1                    py37_0  
numpy                     1.17.2           py37haad9e8e_0  
numpy-base                1.17.2           py37hde5b4d6_0  
olefile                   0.46                     py37_0  
openssl                   1.1.1d               h7b6447c_3  
owslib                    0.18.0                     py_0  
packaging                 19.2                       py_0  
pandas                    0.25.2           py37he6710b0_0  
pandoc                    2.2.3.2                       0  
pandocfilters             1.4.2                    py37_1  
panel                     0.7.0                      py_0    pyviz
param                     1.9.2                      py_0    pyviz
parso                     0.5.1                      py_0  
partd                     1.0.0                      py_0  
pcre                      8.43                 he6710b0_0  
pexpect                   4.7.0                    py37_0  
pickleshare               0.7.5                    py37_0  
pillow                    6.2.0            py37h34e0f95_0  
pip                       19.3.1                   py37_0  
pluggy                    0.13.0                   pypi_0    pypi
proj4                     5.2.0                he6710b0_1  
prometheus_client         0.7.1                      py_0  
prompt_toolkit            2.0.10                     py_0  
psutil                    5.6.3            py37h7b6447c_0  
ptyprocess                0.6.0                    py37_0  
py                        1.8.0                    pypi_0    pypi
pycosat                   0.6.3            py37h14c3975_0  
pycparser                 2.19                     py37_0  
pyct                      0.4.6                      py_0    pyviz
pyct-core                 0.4.6                      py_0    pyviz
pyepsg                    0.4.0                    py37_0  
pygments                  2.4.2                      py_0  
pykdtree                  1.3.1            py37hdd07704_2  
pyopenssl                 19.0.0                   py37_0  
pyparsing                 2.4.2                      py_0  
pyproj                    1.9.6            py37h14380d9_0  
pyqt                      5.9.2            py37h05f1152_2  
pyrsistent                0.15.4           py37h7b6447c_0  
pyshp                     2.1.0                      py_0  
pysocks                   1.7.1                    py37_0  
pytest                    5.2.4                    pypi_0    pypi
python                    3.7.4                h265db76_1  
python-dateutil           2.8.0                    py37_0  
pytz                      2019.3                     py_0  
pyviz_comms               0.7.2                      py_0    pyviz
pyyaml                    5.1.2            py37h7b6447c_0  
pyzmq                     18.1.0           py37he6710b0_0  
qt                        5.9.7                h5867ecd_1  
qtconsole                 4.5.5                      py_0  
readline                  7.0                  h7b6447c_5  
requests                  2.22.0                   py37_0  
ruamel_yaml               0.15.46          py37h14c3975_0  
scipy                     1.3.1            py37h7c811a0_0  
send2trash                1.5.0                    py37_0  
setuptools                41.4.0                   py37_0  
shapely                   1.6.4            py37h86c5351_0  
sip                       4.19.8           py37hf484d3e_0  
six                       1.12.0                   py37_0  
sortedcontainers          2.1.0                    py37_0  
sqlite                    3.30.0               h7b6447c_0  
tblib                     1.5.0                      py_0  
terminado                 0.8.2                    py37_0  
testpath                  0.4.2                    py37_0  
tk                        8.6.8                hbc83047_0  
toolz                     0.10.0                     py_0  
tornado                   6.0.3            py37h7b6447c_0  
tqdm                      4.36.1                     py_0  
traitlets                 4.3.3                    py37_0  
urllib3                   1.24.2                   py37_0  
wcwidth                   0.1.7                    py37_0  
webencodings              0.5.1                    py37_1  
wheel                     0.33.6                   py37_0  
widgetsnbextension        3.5.1                    py37_0  
xarray                    0.13.0                     py_0  
xesmf                     0.2.1                      py_0    conda-forge
xz                        5.2.4                h14c3975_4  
yaml                      0.1.7                had09818_2  
zeromq                    4.3.1                he6710b0_3  
zict                      1.0.0                      py_0  
zipp                      0.6.0                      py_0  
zlib                      1.2.11               h7b6447c_3  
zstd                      1.3.7                h0b5b093_0 

pip list

Package                Version    
---------------------- -----------
asn1crypto             1.2.0      
atomicwrites           1.3.0      
attrs                  19.3.0     
backcall               0.1.0      
bleach                 3.1.0      
bokeh                  1.4.0      
Cartopy                0.17.0     
certifi                2019.9.11  
cffi                   1.13.0     
cftime                 1.0.3.4    
chardet                3.0.4      
Click                  7.0        
cloudpickle            1.2.2      
conda                  4.7.12     
conda-package-handling 1.6.0      
cryptography           2.8        
cycler                 0.10.0     
cytoolz                0.10.1     
dask                   2.8.0      
decorator              4.4.0      
defusedxml             0.6.0      
distributed            2.8.0      
entrypoints            0.3        
ESMPy                  8.0.0      
fsspec                 0.6.0      
HeapDict               1.0.1      
holoviews              1.12.6     
idna                   2.8        
importlib-metadata     0.23       
ipykernel              5.1.2      
ipython                7.8.0      
ipython-genutils       0.2.0      
ipywidgets             7.5.1      
jedi                   0.15.1     
Jinja2                 2.10.3     
jsonschema             3.1.1      
jupyter                1.0.0      
jupyter-client         5.3.4      
jupyter-console        6.0.0      
jupyter-core           4.6.0      
kiwisolver             1.1.0      
locket                 0.2.0      
lxml                   4.4.1      
Markdown               3.1.1      
MarkupSafe             1.1.1      
matplotlib             3.1.1      
mistune                0.8.4      
mkl-fft                1.0.14     
mkl-random             1.1.0      
mkl-service            2.3.0      
more-itertools         7.2.0      
msgpack                0.6.1      
nbconvert              5.6.0      
nbformat               4.4.0      
netCDF4                1.5.3      
notebook               6.0.1      
numpy                  1.17.2     
olefile                0.46       
OWSLib                 0.18.0     
packaging              19.2       
pandas                 0.25.2     
pandocfilters          1.4.2      
panel                  0.7.0      
param                  1.9.2      
parso                  0.5.1      
partd                  1.0.0      
pexpect                4.7.0      
pickleshare            0.7.5      

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions