Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

indicate_inset_zoom not working on some projections #2482

Open
guidocioni opened this issue Nov 21, 2024 · 4 comments
Open

indicate_inset_zoom not working on some projections #2482

guidocioni opened this issue Nov 21, 2024 · 4 comments

Comments

@guidocioni
Copy link

Description

On most non-standard projections (like TransverseMercator) the connectors to an inset axis are not drawn correctly.

Code to reproduce

map_proj = ccrs.TransverseMercator()


fig, ax = plt.subplots(
    figsize=(15, 15),
    subplot_kw={
        "projection": map_proj
    },
)

ax.set_extent([-50, 15, 50, 70], crs=ccrs.PlateCarree())
ax.add_feature(cfeature.OCEAN.with_scale('50m'), facecolor="lightsteelblue", zorder=1)
ax.coastlines(linewidth=0.2, zorder=2, resolution='50m')

# Add inset
inset_ax = inset_axes(
    ax,
    width="30%",  # Width as a percentage of the parent axes
    height="30%",  # Height as a percentage of the parent axes
    loc='lower left',  # Location of the inset
    bbox_to_anchor=(0, 0, 1, 1),
    bbox_transform=ax.transAxes,
    axes_class=GeoAxes,
    axes_kwargs=dict(projection=map_proj)
)
inset_extent = [-43, -39, 63, 66] 
inset_ax.set_extent(inset_extent, crs=ccrs.PlateCarree())
# Add features to inset
inset_ax.add_feature(cfeature.OCEAN, facecolor="lightsteelblue", zorder=1)
inset_ax.coastlines(linewidth=0.5, zorder=2, resolution='50m')

# Add box around location of inset map on the main map
x = [inset_extent[0], inset_extent[1], inset_extent[1], inset_extent[0], inset_extent[0]]
y = [inset_extent[2], inset_extent[2], inset_extent[3], inset_extent[3], inset_extent[2]]
ax.plot(x, y, color='k', alpha=0.5, transform=ccrs.PlateCarree())
# Draw lines between inset map and box on main map
rect, connectors = ax.indicate_inset_zoom(inset_ax, edgecolor="black", alpha=0.5, transform=ax.transAxes)

produces this
1a6cc193-d51c-4144-aa4b-6df8ff89b73d

However, for some projections like Mercator or PlateCarree, it works

d0875706-03a6-4a71-a0e2-a403da2d6a5c

Full environment definition

Cartopy version

0.24.0

conda list

# Name                    Version                   Build  Channel
aemet-opendata            0.5.4                    pypi_0    pypi
aenum                     3.1.15             pyhd8ed1ab_0    conda-forge
affine                    2.4.0              pyhd8ed1ab_0    conda-forge
aiohttp                   3.9.5           py312h41838bb_0    conda-forge
aiosignal                 1.3.1              pyhd8ed1ab_0    conda-forge
annotated-types           0.7.0              pyhd8ed1ab_0    conda-forge
anyio                     4.6.0              pyhd8ed1ab_1    conda-forge
appdirs                   1.4.4              pyh9f0ad1d_0    conda-forge
appnope                   0.1.4              pyhd8ed1ab_0    conda-forge
argon2-cffi               23.1.0             pyhd8ed1ab_0    conda-forge
argon2-cffi-bindings      21.2.0          py312hb553811_5    conda-forge
arrow                     1.3.0              pyhd8ed1ab_0    conda-forge
asciitree                 0.3.3                      py_2    conda-forge
asttokens                 2.4.1              pyhd8ed1ab_0    conda-forge
async-lru                 2.0.4              pyhd8ed1ab_0    conda-forge
attrs                     24.2.0             pyh71513ae_0    conda-forge
aws-c-auth                0.7.30               h0e83244_0    conda-forge
aws-c-cal                 0.7.4                h8128ea2_1    conda-forge
aws-c-common              0.9.28               h00291cd_0    conda-forge
aws-c-compression         0.2.19               h8128ea2_1    conda-forge
aws-c-event-stream        0.4.3                hcd1ed9e_2    conda-forge
aws-c-http                0.8.9                h2f86973_0    conda-forge
aws-c-io                  0.14.18             hf9a0f1c_10    conda-forge
aws-c-mqtt                0.10.5               h3e3652f_0    conda-forge
aws-c-s3                  0.6.5                hf761692_5    conda-forge
aws-c-sdkutils            0.1.19               h8128ea2_3    conda-forge
aws-checksums             0.1.20               h8128ea2_0    conda-forge
aws-crt-cpp               0.28.2               heb037f6_6    conda-forge
aws-sdk-cpp               1.11.379            hd82b0e1_10    conda-forge
azure-core-cpp            1.13.0               hf8dbe3c_0    conda-forge
azure-identity-cpp        1.8.0                h60298e3_2    conda-forge
azure-storage-blobs-cpp   12.12.0              h646f05d_0    conda-forge
azure-storage-common-cpp  12.7.0               hf91904f_1    conda-forge
azure-storage-files-datalake-cpp 12.11.0              h14965f0_1    conda-forge
babel                     2.14.0             pyhd8ed1ab_0    conda-forge
backports-datetime-fromisoformat 2.0.2           py312hb401068_0    conda-forge
basemap                   1.4.1           np126py312hb3450bc_0    conda-forge
basemap-data              1.3.2              pyhd8ed1ab_3    conda-forge
basemap-data-hires        1.3.2              pyhd8ed1ab_3    conda-forge
beautifulsoup4            4.12.3             pyha770c72_0    conda-forge
bleach                    6.1.0              pyhd8ed1ab_0    conda-forge
blinker                   1.8.2              pyhd8ed1ab_0    conda-forge
blosc                     1.21.6               h7d75f6d_0    conda-forge
bokeh                     3.5.2              pyhd8ed1ab_0    conda-forge
boltons                   24.0.0             pyhd8ed1ab_0    conda-forge
boto3                     1.35.34            pyhd8ed1ab_0    conda-forge
botocore                  1.35.34         pyge310_1234567_0    conda-forge
bottleneck                1.4.0           py312h3a11e2b_2    conda-forge
branca                    0.7.2              pyhd8ed1ab_0    conda-forge
brotli                    1.1.0                h00291cd_2    conda-forge
brotli-bin                1.1.0                h00291cd_2    conda-forge
brotli-python             1.1.0           py312h5861a67_2    conda-forge
bzip2                     1.0.8                hfdf4475_7    conda-forge
c-ares                    1.33.1               h44e7173_0    conda-forge
ca-certificates           2024.8.30            h8857fd0_0    conda-forge
cached-property           1.5.2                hd8ed1ab_1    conda-forge
cached_property           1.5.2              pyha770c72_1    conda-forge
cachelib                  0.9.0              pyhd8ed1ab_0    conda-forge
cachetools                5.5.0              pyhd8ed1ab_0    conda-forge
cachier                   3.0.1              pyhd8ed1ab_0    conda-forge
cairo                     1.18.0               h37bd5c4_3    conda-forge
cartopy                   0.24.0          py312h98e817e_0    conda-forge
cctools_osx-64            973.0.1             habff3f6_15    conda-forge
cdo                       2.4.1                h70e7d24_1    conda-forge
certifi                   2024.8.30          pyhd8ed1ab_0    conda-forge
cf_xarray                 0.9.5              pyhd8ed1ab_1    conda-forge
cffi                      1.17.1          py312hf857d28_0    conda-forge
cfgrib                    0.9.14.1           pyhd8ed1ab_0    conda-forge
cfitsio                   4.4.1                ha105788_0    conda-forge
cftime                    1.6.4           py312h3a11e2b_1    conda-forge
charset-normalizer        3.3.2              pyhd8ed1ab_0    conda-forge
clang                     15.0.7               hdae98eb_5    conda-forge
clang-15                  15.0.7          default_h7151d67_5    conda-forge
clang_impl_osx-64         15.0.7               h03d6864_8    conda-forge
clang_osx-64              15.0.7               hb91bd55_8    conda-forge
clangxx                   15.0.7          default_h7151d67_5    conda-forge
clangxx_impl_osx-64       15.0.7               h2133e9c_8    conda-forge
clangxx_osx-64            15.0.7               hb91bd55_8    conda-forge
click                     8.1.7           unix_pyh707e725_0    conda-forge
click-params              0.5.0              pyhd8ed1ab_0    conda-forge
click-plugins             1.1.1                      py_0    conda-forge
cligj                     0.7.2              pyhd8ed1ab_1    conda-forge
cloudpickle               3.0.0              pyhd8ed1ab_0    conda-forge
cloup                     3.0.5              pyhd8ed1ab_0    conda-forge
cmdstan                   2.33.1               ha749d2a_0    conda-forge
cmdstanpy                 1.2.4              pyhd8ed1ab_0    conda-forge
cmweather                 0.3.2              pyhd8ed1ab_0    conda-forge
colorama                  0.4.6              pyhd8ed1ab_0    conda-forge
colorcet                  3.1.0              pyhd8ed1ab_0    conda-forge
comm                      0.2.2              pyhd8ed1ab_0    conda-forge
compiler-rt               15.0.7               ha38d28d_2    conda-forge
compiler-rt_osx-64        15.0.7               ha38d28d_2    conda-forge
configobj                 5.0.9              pyhd8ed1ab_0    conda-forge
contourpy                 1.3.0           py312hc5c4d5f_2    conda-forge
convertdate               2.4.0              pyhd8ed1ab_0    conda-forge
copernicusmarine          1.3.3              pyhd8ed1ab_0    conda-forge
cycler                    0.12.1             pyhd8ed1ab_0    conda-forge
cyrus-sasl                2.1.27               hf9bab2b_7    conda-forge
cytoolz                   1.0.0           py312hb553811_0    conda-forge
dash                      2.18.1             pyhd8ed1ab_0    conda-forge
dash-bootstrap-components 1.6.0              pyhd8ed1ab_0    conda-forge
dash-iconify              0.1.2              pyhd8ed1ab_0    conda-forge
dash-leaflet              1.0.15             pyhd8ed1ab_0    conda-forge
dash-mantine-components   0.14.4             pyhd8ed1ab_0    conda-forge
dask                      2024.9.1           pyhd8ed1ab_0    conda-forge
dask-core                 2024.9.1           pyhd8ed1ab_0    conda-forge
dask-expr                 1.1.15             pyhd8ed1ab_0    conda-forge
dataclasses               0.8                pyhc8e2a94_3    conda-forge
debugpy                   1.8.6           py312h5861a67_0    conda-forge
decorator                 5.1.1              pyhd8ed1ab_0    conda-forge
defusedxml                0.7.1              pyhd8ed1ab_0    conda-forge
deprecated                1.2.14             pyh1a96a4e_0    conda-forge
deprecation               2.1.0              pyh9f0ad1d_0    conda-forge
dill                      0.3.9              pyhd8ed1ab_0    conda-forge
diskcache                 5.6.3              pyhd8ed1ab_0    conda-forge
distributed               2024.9.1           pyhd8ed1ab_0    conda-forge
distro                    1.9.0              pyhd8ed1ab_0    conda-forge
dnspython                 2.7.0              pyhff2d567_0    conda-forge
docopt                    0.6.2                      py_1    conda-forge
docopt-ng                 0.9.0              pyhd8ed1ab_0    conda-forge
donfig                    0.8.1.post1        pyhd8ed1ab_0    conda-forge
eccodes                   2.38.0               he0f85d2_0    conda-forge
ecmwf-opendata            0.3.10             pyhd8ed1ab_0    conda-forge
entrypoints               0.4                pyhd8ed1ab_0    conda-forge
environs                  11.0.0             pyhd8ed1ab_1    conda-forge
ephem                     4.1.5           py312hb553811_2    conda-forge
eumdac                    2.2.3              pyhd8ed1ab_0    conda-forge
eval-type-backport        0.2.0              pyhd8ed1ab_0    conda-forge
eval_type_backport        0.2.0              pyha770c72_0    conda-forge
exceptiongroup            1.2.2              pyhd8ed1ab_0    conda-forge
executing                 2.1.0              pyhd8ed1ab_0    conda-forge
expat                     2.6.3                hac325c4_0    conda-forge
fasteners                 0.17.3             pyhd8ed1ab_0    conda-forge
fftw                      3.3.10          nompi_h292e606_110    conda-forge
filelock                  3.16.1             pyhd8ed1ab_0    conda-forge
findlibs                  0.0.5              pyhd8ed1ab_0    conda-forge
fiona                     1.9.6           py312hfc836c0_3    conda-forge
flask                     3.0.3              pyhd8ed1ab_0    conda-forge
flask-caching             2.1.0              pyhd8ed1ab_0    conda-forge
flexcache                 0.3                pyhd8ed1ab_0    conda-forge
flexparser                0.3.1              pyhd8ed1ab_0    conda-forge
fmt                       11.0.2               h3c5361c_0    conda-forge
folium                    0.17.0             pyhd8ed1ab_0    conda-forge
font-ttf-dejavu-sans-mono 2.37                 hab24e00_0    conda-forge
font-ttf-inconsolata      3.000                h77eed37_0    conda-forge
font-ttf-source-code-pro  2.038                h77eed37_0    conda-forge
font-ttf-ubuntu           0.83                 h77eed37_3    conda-forge
fontconfig                2.14.2               h5bb23bf_0    conda-forge
fonts-conda-ecosystem     1                             0    conda-forge
fonts-conda-forge         1                             0    conda-forge
fonttools                 4.54.1          py312hb553811_0    conda-forge
fqdn                      1.5.1              pyhd8ed1ab_0    conda-forge
freetype                  2.12.1               h60636b9_2    conda-forge
freexl                    2.0.0                h3ec172f_0    conda-forge
fribidi                   1.0.10               hbcb3906_0    conda-forge
frozenlist                1.4.1           py312hb553811_1    conda-forge
fsspec                    2024.9.0           pyhff2d567_0    conda-forge
gdal                      3.9.1           py312h9b1be66_3    conda-forge
geobuf                    1.1.1              pyh9f0ad1d_0    conda-forge
geographiclib             2.0                      pypi_0    pypi
geopandas                 1.0.1              pyhd8ed1ab_1    conda-forge
geopandas-base            1.0.1              pyha770c72_1    conda-forge
geopy                     2.4.1                    pypi_0    pypi
geos                      3.12.1               h93d8f39_0    conda-forge
geotiff                   1.7.3                h4bbec01_2    conda-forge
gettext                   0.22.5               hdfe23c8_3    conda-forge
gettext-tools             0.22.5               hdfe23c8_3    conda-forge
gflags                    2.2.2             hac325c4_1005    conda-forge
giflib                    5.2.2                h10d778d_0    conda-forge
glog                      0.7.1                h2790a97_0    conda-forge
gmp                       6.3.0                hf036a51_2    conda-forge
gmpy2                     2.1.5           py312h165121d_2    conda-forge
graphite2                 1.3.13            h73e2aa4_1003    conda-forge
h11                       0.14.0             pyhd8ed1ab_0    conda-forge
h2                        4.1.0              pyhd8ed1ab_0    conda-forge
h5netcdf                  1.3.0              pyhd8ed1ab_0    conda-forge
h5py                      3.11.0          nompi_py312hfc94b03_102    conda-forge
harfbuzz                  9.0.0                h098a298_1    conda-forge
hdf4                      4.2.15               h8138101_7    conda-forge
hdf5                      1.14.3          nompi_h687a608_105    conda-forge
hdf5plugin                5.0.0           py312h54c024f_0    conda-forge
holidays                  0.57               pyhd8ed1ab_0    conda-forge
holoviews                 1.19.1             pyhd8ed1ab_0    conda-forge
hpack                     4.0.0              pyh9f0ad1d_0    conda-forge
html5lib                  1.1                pyh9f0ad1d_0    conda-forge
httpcore                  1.0.6              pyhd8ed1ab_0    conda-forge
httpx                     0.27.2             pyhd8ed1ab_0    conda-forge
hvplot                    0.11.0             pyhd8ed1ab_0    conda-forge
hyperframe                6.0.1              pyhd8ed1ab_0    conda-forge
icu                       75.1                 h120a0e1_0    conda-forge
idna                      3.10               pyhd8ed1ab_0    conda-forge
importlib-metadata        8.5.0              pyha770c72_0    conda-forge
importlib-resources       6.4.5              pyhd8ed1ab_0    conda-forge
importlib_metadata        8.5.0                hd8ed1ab_0    conda-forge
importlib_resources       6.4.5              pyhd8ed1ab_0    conda-forge
ipykernel                 6.29.5             pyh57ce528_0    conda-forge
ipython                   8.28.0             pyh707e725_0    conda-forge
ipywidgets                8.1.5              pyhd8ed1ab_0    conda-forge
isoduration               20.11.0            pyhd8ed1ab_0    conda-forge
itsdangerous              2.2.0              pyhd8ed1ab_0    conda-forge
jasper                    4.2.4                hb10263b_0    conda-forge
jdcal                     1.4.1                      py_0    conda-forge
jedi                      0.19.1             pyhd8ed1ab_0    conda-forge
jinja2                    3.1.4              pyhd8ed1ab_0    conda-forge
jiter                     0.5.0           py312h669792a_1    conda-forge
jmespath                  1.0.1              pyhd8ed1ab_0    conda-forge
joblib                    1.4.2              pyhd8ed1ab_0    conda-forge
json-c                    0.17                 h6253ea5_1    conda-forge
json5                     0.9.25             pyhd8ed1ab_0    conda-forge
jsonpickle                3.3.0              pyhd8ed1ab_0    conda-forge
jsonpointer               3.0.0           py312hb401068_1    conda-forge
jsonschema                4.23.0             pyhd8ed1ab_0    conda-forge
jsonschema-specifications 2023.12.1          pyhd8ed1ab_0    conda-forge
jsonschema-with-format-nongpl 4.23.0               hd8ed1ab_0    conda-forge
jupyter                   1.1.1              pyhd8ed1ab_0    conda-forge
jupyter-lsp               2.2.5              pyhd8ed1ab_0    conda-forge
jupyter_client            8.6.3              pyhd8ed1ab_0    conda-forge
jupyter_console           6.6.3              pyhd8ed1ab_0    conda-forge
jupyter_core              5.7.2              pyh31011fe_1    conda-forge
jupyter_events            0.10.0             pyhd8ed1ab_0    conda-forge
jupyter_server            2.14.2             pyhd8ed1ab_0    conda-forge
jupyter_server_terminals  0.5.3              pyhd8ed1ab_0    conda-forge
jupyterlab                4.2.5              pyhd8ed1ab_0    conda-forge
jupyterlab_pygments       0.3.0              pyhd8ed1ab_1    conda-forge
jupyterlab_server         2.27.3             pyhd8ed1ab_0    conda-forge
jupyterlab_widgets        3.0.13             pyhd8ed1ab_0    conda-forge
kealib                    1.5.3                he475af8_2    conda-forge
kiwisolver                1.4.7           py312hc5c4d5f_0    conda-forge
krb5                      1.21.3               h37d8d59_0    conda-forge
lat_lon_parser            1.3.0              pyhd8ed1ab_0    conda-forge
lcms2                     2.16                 ha2f27b4_0    conda-forge
ld64_osx-64               609                 h0fd476b_15    conda-forge
lerc                      4.0.0                hb486fe8_0    conda-forge
libabseil                 20240116.2      cxx17_hf036a51_1    conda-forge
libaec                    1.1.3                h73e2aa4_0    conda-forge
libarchive                3.7.4                h20e244c_0    conda-forge
libarrow                  17.0.0          ha60c65e_13_cpu    conda-forge
libarrow-acero            17.0.0          hac325c4_13_cpu    conda-forge
libarrow-dataset          17.0.0          hac325c4_13_cpu    conda-forge
libarrow-flight           17.0.0          hea76c88_13_cpu    conda-forge
libarrow-flight-sql       17.0.0          h824516f_13_cpu    conda-forge
libarrow-gandiva          17.0.0          h8c10372_13_cpu    conda-forge
libarrow-substrait        17.0.0          hba007a9_13_cpu    conda-forge
libasprintf               0.22.5               hdfe23c8_3    conda-forge
libasprintf-devel         0.22.5               hdfe23c8_3    conda-forge
libblas                   3.9.0           22_osx64_openblas    conda-forge
libboost-headers          1.86.0               h694c41f_2    conda-forge
libbrotlicommon           1.1.0                h00291cd_2    conda-forge
libbrotlidec              1.1.0                h00291cd_2    conda-forge
libbrotlienc              1.1.0                h00291cd_2    conda-forge
libcblas                  3.9.0           22_osx64_openblas    conda-forge
libclang-cpp15            15.0.7          default_h7151d67_5    conda-forge
libcrc32c                 1.1.2                he49afe7_0    conda-forge
libcurl                   8.10.1               h58e7537_0    conda-forge
libcxx                    19.1.1               hf95d169_0    conda-forge
libdeflate                1.20                 h49d49c5_0    conda-forge
libedit                   3.1.20191231         h0678c8f_2    conda-forge
libev                     4.33                 h10d778d_2    conda-forge
libevent                  2.1.12               ha90c15b_1    conda-forge
libexpat                  2.6.3                hac325c4_0    conda-forge
libffi                    3.4.2                h0d85af4_5    conda-forge
libgdal                   3.9.1                hb1a0af8_3    conda-forge
libgettextpo              0.22.5               hdfe23c8_3    conda-forge
libgettextpo-devel        0.22.5               hdfe23c8_3    conda-forge
libgfortran               5.0.0           13_2_0_h97931a8_3    conda-forge
libgfortran5              13.2.0               h2873a65_3    conda-forge
libglib                   2.82.1               h63bbcf2_0    conda-forge
libgoogle-cloud           2.28.0               h721cda5_0    conda-forge
libgoogle-cloud-storage   2.28.0               h9e84e37_0    conda-forge
libgrpc                   1.62.2               h384b2fc_0    conda-forge
libhwloc                  2.11.1          default_h456cccd_1000    conda-forge
libiconv                  1.17                 hd75f5a5_2    conda-forge
libintl                   0.22.5               hdfe23c8_3    conda-forge
libintl-devel             0.22.5               hdfe23c8_3    conda-forge
libjpeg-turbo             3.0.0                h0dc2134_1    conda-forge
libkml                    1.3.0             h9ee1731_1021    conda-forge
liblapack                 3.9.0           22_osx64_openblas    conda-forge
libllvm14                 14.0.6               hc8e404f_4    conda-forge
libllvm15                 15.0.7               hbedff68_4    conda-forge
libllvm17                 17.0.6               hbedff68_1    conda-forge
libllvm18                 18.1.8               h9ce406d_2    conda-forge
libnetcdf                 4.9.2           nompi_h7334405_114    conda-forge
libnghttp2                1.58.0               h64cf6d3_1    conda-forge
libntlm                   1.4               h0d85af4_1002    conda-forge
libopenblas               0.3.27          openmp_h8869122_1    conda-forge
libparquet                17.0.0          hf1b0f52_13_cpu    conda-forge
libpng                    1.6.44               h4b8f8c9_0    conda-forge
libpq                     16.4                 h75a757a_2    conda-forge
libprotobuf               4.25.3               hd4aba4c_1    conda-forge
libre2-11                 2023.09.01           h81f5012_2    conda-forge
librttopo                 1.1.0               hf05f67e_15    conda-forge
libsodium                 1.0.20               hfdf4475_0    conda-forge
libspatialindex           2.0.0                hf036a51_0    conda-forge
libspatialite             5.1.0                h5579707_7    conda-forge
libsqlite                 3.46.1               h4b8f8c9_0    conda-forge
libssh2                   1.11.0               hd019ec5_0    conda-forge
libthrift                 0.20.0               h75589b3_1    conda-forge
libtiff                   4.6.0                h129831d_3    conda-forge
libudunits2               2.2.28               h516ac8c_3    conda-forge
libutf8proc               2.8.0                hb7f2c08_0    conda-forge
libuuid                   2.38.1               hb7f2c08_0    conda-forge
libwebp-base              1.4.0                h10d778d_0    conda-forge
libxcb                    1.17.0               hf1f96e2_0    conda-forge
libxml2                   2.12.7               heaf3512_4    conda-forge
libxslt                   1.1.39               h03b04e6_0    conda-forge
libzip                    1.11.1               h3116616_0    conda-forge
libzlib                   1.3.1                hd23fc13_2    conda-forge
linkify-it-py             2.0.3              pyhd8ed1ab_0    conda-forge
llvm-openmp               19.1.0               h56322cc_0    conda-forge
llvm-tools                15.0.7               hbedff68_4    conda-forge
llvmlite                  0.43.0          py312hcc8fd36_1    conda-forge
locket                    1.0.0              pyhd8ed1ab_0    conda-forge
lunarcalendar             0.0.9                      py_0    conda-forge
lxml                      5.3.0           py312h4feaf87_1    conda-forge
lz4                       4.3.3           py312h83408cd_1    conda-forge
lz4-c                     1.9.4                hf0c8a7f_0    conda-forge
lzo                       2.10              h10d778d_1001    conda-forge
magics                    4.15.4               hbffab32_1    conda-forge
magics-python             1.5.8              pyhd8ed1ab_1    conda-forge
make                      4.4.1                h00291cd_2    conda-forge
mapclassify               2.8.1              pyhd8ed1ab_0    conda-forge
markdown                  3.6                pyhd8ed1ab_0    conda-forge
markdown-it-py            3.0.0              pyhd8ed1ab_0    conda-forge
markupsafe                2.1.5           py312hb553811_1    conda-forge
marshmallow               3.22.0             pyhd8ed1ab_0    conda-forge
matplotlib                3.8.4           py312hb401068_2    conda-forge
matplotlib-base           3.8.4           py312hb6d62fa_2    conda-forge
matplotlib-inline         0.1.7              pyhd8ed1ab_0    conda-forge
mdit-py-plugins           0.4.2              pyhd8ed1ab_0    conda-forge
mdurl                     0.1.2              pyhd8ed1ab_0    conda-forge
measurement               3.2.0                      py_1    conda-forge
metpy                     1.6.3              pyhd8ed1ab_0    conda-forge
minizip                   4.0.7                h62b0c8d_0    conda-forge
mistune                   3.0.2              pyhd8ed1ab_0    conda-forge
mpc                       1.3.1                h9d8efa1_1    conda-forge
mpfr                      4.2.1                haed47dc_3    conda-forge
mpmath                    1.3.0              pyhd8ed1ab_0    conda-forge
msgpack-python            1.1.0           py312hc5c4d5f_0    conda-forge
multidict                 6.1.0           py312h9131086_0    conda-forge
multiprocess              0.70.16         py312hb553811_1    conda-forge
multiurl                  0.3.1              pyhd8ed1ab_0    conda-forge
munkres                   1.1.4              pyh9f0ad1d_0    conda-forge
nbclient                  0.10.0             pyhd8ed1ab_0    conda-forge
nbconvert                 7.16.4               hd8ed1ab_1    conda-forge
nbconvert-core            7.16.4             pyhd8ed1ab_1    conda-forge
nbconvert-pandoc          7.16.4               hd8ed1ab_1    conda-forge
nbformat                  5.10.4             pyhd8ed1ab_0    conda-forge
ncurses                   6.5                  hf036a51_1    conda-forge
nest-asyncio              1.6.0              pyhd8ed1ab_0    conda-forge
netcdf4                   1.7.1           nompi_py312h683d7b0_102    conda-forge
networkx                  3.3                pyhd8ed1ab_1    conda-forge
notebook                  7.2.2              pyhd8ed1ab_0    conda-forge
notebook-shim             0.2.4              pyhd8ed1ab_0    conda-forge
nspr                      4.35                 hea0b92c_0    conda-forge
nss                       3.105                h3135457_0    conda-forge
numba                     0.60.0          py312hc3b515d_0    conda-forge
numcodecs                 0.13.0          py312h1171441_0    conda-forge
numpy                     1.26.4          py312he3a82b2_0    conda-forge
ollama                    0.1.17           cpu_he06a1bc_0    conda-forge
openai                    1.51.0             pyhd8ed1ab_0    conda-forge
openjpeg                  2.5.2                h7310d3a_0    conda-forge
openldap                  2.6.8                hcd2896d_0    conda-forge
openssl                   3.4.0                hd471939_0    conda-forge
orc                       2.0.2                h22b2039_0    conda-forge
overrides                 7.7.0              pyhd8ed1ab_0    conda-forge
owslib                    0.31.0             pyhd8ed1ab_0    conda-forge
packaging                 24.1               pyhd8ed1ab_0    conda-forge
pandas                    2.2.3           py312h98e817e_1    conda-forge
pandoc                    3.5                  h694c41f_0    conda-forge
pandocfilters             1.5.0              pyhd8ed1ab_0    conda-forge
panel                     1.5.2              pyhd8ed1ab_0    conda-forge
pango                     1.54.0               h115fe74_2    conda-forge
param                     2.1.1              pyhff2d567_0    conda-forge
parso                     0.8.4              pyhd8ed1ab_0    conda-forge
partd                     1.4.2              pyhd8ed1ab_0    conda-forge
patsy                     0.5.6              pyhd8ed1ab_0    conda-forge
pcre2                     10.44                h7634a1b_2    conda-forge
pexpect                   4.9.0              pyhd8ed1ab_0    conda-forge
pickleshare               0.7.5                   py_1003    conda-forge
pillow                    10.4.0          py312h683ea77_1    conda-forge
pint                      0.24.3             pyhd8ed1ab_0    conda-forge
pip                       24.2               pyh8b19718_1    conda-forge
pixman                    0.43.4               h73e2aa4_0    conda-forge
pkgutil-resolve-name      1.3.10             pyhd8ed1ab_1    conda-forge
platformdirs              4.3.6              pyhd8ed1ab_0    conda-forge
plotly                    5.24.1             pyhd8ed1ab_0    conda-forge
polars                    1.9.0           py312h088783b_0    conda-forge
pooch                     1.8.2              pyhd8ed1ab_0    conda-forge
poppler                   24.04.0              h0face88_0    conda-forge
poppler-data              0.4.12               hd8ed1ab_0    conda-forge
portalocker               2.10.1          py312hb401068_0    conda-forge
portion                   2.5.0              pyhd8ed1ab_0    conda-forge
postgresql                16.4                 h4b98a8f_2    conda-forge
proj                      9.4.1                hf92c781_1    conda-forge
prometheus_client         0.21.0             pyhd8ed1ab_0    conda-forge
prompt-toolkit            3.0.48             pyha770c72_0    conda-forge
prompt_toolkit            3.0.48               hd8ed1ab_0    conda-forge
prophet                   1.1.5           py312h3264805_1    conda-forge
protobuf                  4.25.3          py312hd13efa9_1    conda-forge
psutil                    6.0.0           py312hb553811_1    conda-forge
pthread-stubs             0.4               h00291cd_1002    conda-forge
ptyprocess                0.7.0              pyhd3deb0d_0    conda-forge
pure_eval                 0.2.3              pyhd8ed1ab_0    conda-forge
pyarrow                   17.0.0          py312h0be7463_1    conda-forge
pyarrow-core              17.0.0          py312h63b501a_1_cpu    conda-forge
pyarrow-hotfix            0.6                pyhd8ed1ab_0    conda-forge
pycparser                 2.22               pyhd8ed1ab_0    conda-forge
pydantic                  2.9.2              pyhd8ed1ab_0    conda-forge
pydantic-core             2.23.4          py312h669792a_0    conda-forge
pydap                     3.5                pyhd8ed1ab_0    conda-forge
pygments                  2.18.0             pyhd8ed1ab_0    conda-forge
pykdtree                  1.3.13          py312h3a11e2b_1    conda-forge
pymeeus                   0.5.12             pyhd8ed1ab_0    conda-forge
pymongo                   4.10.1          py312h5861a67_0    conda-forge
pyobjc-core               10.3.1          py312hab44e94_1    conda-forge
pyobjc-framework-cocoa    10.3.1          py312hab44e94_1    conda-forge
pyogrio                   0.9.0           py312h43b3a95_0    conda-forge
pyorbital                 1.8.3              pyhd8ed1ab_0    conda-forge
pyparsing                 3.1.4              pyhd8ed1ab_0    conda-forge
pypdf                     5.0.1              pyha770c72_0    conda-forge
pyproj                    3.6.1           py312haf32e09_9    conda-forge
pyresample                1.30.0          py312h98e817e_0    conda-forge
pyshp                     2.3.1              pyhd8ed1ab_0    conda-forge
pysocks                   1.7.1              pyha2e5f31_6    conda-forge
pyspectral                0.13.5             pyhd8ed1ab_0    conda-forge
pystac                    1.11.0             pyhd8ed1ab_0    conda-forge
python                    3.12.7          h8f8b54e_0_cpython    conda-forge
python-dateutil           2.9.0              pyhd8ed1ab_0    conda-forge
python-dotenv             1.0.1              pyhd8ed1ab_0    conda-forge
python-eccodes            2.37.0          py312h3a11e2b_0    conda-forge
python-fastjsonschema     2.20.0             pyhd8ed1ab_0    conda-forge
python-geotiepoints       1.7.4           py312h5dc8b90_0    conda-forge
python-json-logger        2.0.7              pyhd8ed1ab_0    conda-forge
python-tzdata             2024.2             pyhd8ed1ab_0    conda-forge
python_abi                3.12                    5_cp312    conda-forge
pytz                      2024.1             pyhd8ed1ab_0    conda-forge
pyviz_comms               3.0.3              pyhd8ed1ab_0    conda-forge
pyyaml                    6.0.2           py312hb553811_1    conda-forge
pyzmq                     26.2.0          py312h54d5c6a_2    conda-forge
qhull                     2020.2               h3c5361c_5    conda-forge
qtconsole-base            5.6.0              pyha770c72_0    conda-forge
qtpy                      2.4.1              pyhd8ed1ab_0    conda-forge
rapidfuzz                 3.10.0          py312h5861a67_0    conda-forge
rasterio                  1.3.10          py312h1c98354_4    conda-forge
re2                       2023.09.01           hb168e87_2    conda-forge
readline                  8.2                  h9e318b2_1    conda-forge
referencing               0.35.1             pyhd8ed1ab_0    conda-forge
requests                  2.32.3             pyhd8ed1ab_0    conda-forge
retrying                  1.3.3              pyhd8ed1ab_3    conda-forge
rfc3339-validator         0.1.4              pyhd8ed1ab_0    conda-forge
rfc3986-validator         0.1.1              pyh9f0ad1d_0    conda-forge
rioxarray                 0.17.0             pyhd8ed1ab_0    conda-forge
rpds-py                   0.20.0          py312h669792a_1    conda-forge
rtree                     1.3.0           py312hb560d21_2    conda-forge
s3transfer                0.10.2             pyhd8ed1ab_0    conda-forge
satpy                     0.51.0             pyhd8ed1ab_0    conda-forge
scikit-learn              1.5.2           py312h9d777eb_1    conda-forge
scipy                     1.14.1          py312he82a568_0    conda-forge
seaborn                   0.13.2               hd8ed1ab_2    conda-forge
seaborn-base              0.13.2             pyhd8ed1ab_2    conda-forge
seawater                  3.3.5              pyhd8ed1ab_0    conda-forge
semver                    3.0.2              pyhd8ed1ab_0    conda-forge
send2trash                1.8.3              pyh31c8845_0    conda-forge
setuptools                75.1.0             pyhd8ed1ab_0    conda-forge
shapely                   2.0.4           py312h3daf033_1    conda-forge
sigtool                   0.1.3                h88f4db0_0    conda-forge
simplejson                3.19.3          py312hb553811_1    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
snappy                    1.2.1                he1e6707_0    conda-forge
sniffio                   1.3.1              pyhd8ed1ab_0    conda-forge
snuggs                    1.4.7              pyhd8ed1ab_1    conda-forge
sortedcontainers          2.4.0              pyhd8ed1ab_0    conda-forge
soupsieve                 2.5                pyhd8ed1ab_1    conda-forge
spdlog                    1.14.1               h325aa07_1    conda-forge
sqlite                    3.46.1               he26b093_0    conda-forge
stack_data                0.6.2              pyhd8ed1ab_0    conda-forge
stamina                   24.3.0             pyhd8ed1ab_0    conda-forge
stanio                    0.5.1              pyhd8ed1ab_0    conda-forge
statsmodels               0.14.4          py312h3a11e2b_0    conda-forge
sympy                     1.13.3          pypyh2585a3b_103    conda-forge
tabulate                  0.9.0              pyhd8ed1ab_1    conda-forge
tapi                      1100.0.11            h9ce4665_0    conda-forge
tbb                       2021.13.0            h37c8870_0    conda-forge
tbb-devel                 2021.13.0            hf74753b_0    conda-forge
tblib                     3.0.0              pyhd8ed1ab_0    conda-forge
tenacity                  9.0.0              pyhd8ed1ab_0    conda-forge
terminado                 0.18.1             pyh31c8845_0    conda-forge
threadpoolctl             3.5.0              pyhc1e730c_0    conda-forge
tiledb                    2.24.2              h313d0e2_12    conda-forge
tinycss2                  1.3.0              pyhd8ed1ab_0    conda-forge
tk                        8.6.13               h1abcd95_1    conda-forge
tomli                     2.0.2              pyhd8ed1ab_0    conda-forge
toolz                     1.0.0              pyhd8ed1ab_0    conda-forge
tornado                   6.4.1           py312hb553811_1    conda-forge
tqdm                      4.66.5             pyhd8ed1ab_0    conda-forge
traitlets                 5.14.3             pyhd8ed1ab_0    conda-forge
trollimage                1.25.0          py312h1171441_0    conda-forge
trollsift                 0.5.1              pyhd8ed1ab_0    conda-forge
types-python-dateutil     2.9.0.20241003     pyhff2d567_0    conda-forge
typing-extensions         4.12.2               hd8ed1ab_0    conda-forge
typing_extensions         4.12.2             pyha770c72_0    conda-forge
typing_utils              0.1.0              pyhd8ed1ab_0    conda-forge
tzcode                    2024b                h00291cd_0    conda-forge
tzdata                    2024b                hc8b5060_0    conda-forge
tzfpy                     0.15.6          py312h669792a_1    conda-forge
uc-micro-py               1.0.3              pyhd8ed1ab_0    conda-forge
udunits2                  2.2.28               h516ac8c_3    conda-forge
unidecode                 1.3.8              pyhd8ed1ab_0    conda-forge
uri-template              1.3.0              pyhd8ed1ab_0    conda-forge
uriparser                 0.9.8                h6aefe2f_0    conda-forge
urllib3                   2.2.3              pyhd8ed1ab_0    conda-forge
validators                0.22.0             pyhd8ed1ab_0    conda-forge
watchdog                  5.0.3           py312hb553811_0    conda-forge
wcwidth                   0.2.13             pyhd8ed1ab_0    conda-forge
webcolors                 24.8.0             pyhd8ed1ab_0    conda-forge
webencodings              0.5.1              pyhd8ed1ab_2    conda-forge
webob                     1.8.8              pyhd8ed1ab_0    conda-forge
websocket-client          1.8.0              pyhd8ed1ab_0    conda-forge
werkzeug                  3.0.4              pyhd8ed1ab_0    conda-forge
wheel                     0.44.0             pyhd8ed1ab_0    conda-forge
widgetsnbextension        4.0.13             pyhd8ed1ab_0    conda-forge
wradlib                   2.1.1              pyhd8ed1ab_0    conda-forge
wrapt                     1.16.0          py312hb553811_1    conda-forge
xarray                    2024.9.0           pyhd8ed1ab_0    conda-forge
xarray-datatree           0.0.14             pyhd8ed1ab_0    conda-forge
xclim                     0.52.2             pyhd8ed1ab_0    conda-forge
xerces-c                  3.2.5                h197e74d_2    conda-forge
xlsx2csv                  0.8.3              pyhd8ed1ab_0    conda-forge
xlsxwriter                3.2.0              pyhd8ed1ab_0    conda-forge
xmltodict                 0.13.0             pyhd8ed1ab_0    conda-forge
xorg-libxau               1.0.11               h00291cd_1    conda-forge
xorg-libxdmcp             1.1.5                h00291cd_0    conda-forge
xradar                    0.6.5              pyhd8ed1ab_0    conda-forge
xyzservices               2024.9.0           pyhd8ed1ab_0    conda-forge
xz                        5.2.6                h775f41a_0    conda-forge
yamale                    5.2.1              pyhca7485f_0    conda-forge
yaml                      0.2.5                h0d85af4_2    conda-forge
yarl                      1.13.1          py312hb553811_0    conda-forge
zarr                      2.18.3             pyhd8ed1ab_0    conda-forge
zeromq                    4.3.5                hb33e954_5    conda-forge
zict                      3.0.0              pyhd8ed1ab_0    conda-forge
zipp                      3.20.2             pyhd8ed1ab_0    conda-forge
zlib                      1.3.1                hd23fc13_2    conda-forge
zstandard                 0.23.0          py312h7122b0e_1    conda-forge
zstd                      1.5.6                h915ae27_0    conda-forge
@rcomer
Copy link
Member

rcomer commented Nov 21, 2024

Matplotlib has two versions of inset_axes. You appear to be using the axes_grid version. There is also an axes method version. indicate_axes_zoom is designed to work with Axes.inset_axes whereas the axes_grid version has mark_inset which does a similar job. I have also been confused by this.

I doubt either way will work with Cartopy transforms but, to understand what needs to be done to make it work, we should start with an example that uses the right pair of functions. I suggest that Axes.inset_axes and Axes.indicate_inset_zoom would be the better ones to work with since they are newer, in the main Matplotlib package, and have had recent active development.

@guidocioni
Copy link
Author

guidocioni commented Nov 22, 2024

Matplotlib has two versions of inset_axes. You appear to be using the axes_grid version. There is also an axes method version. indicate_axes_zoom is designed to work with Axes.inset_axes whereas the axes_grid version has mark_inset which does a similar job. I have also been confused by this.

I doubt either way will work with Cartopy transforms but, to understand what needs to be done to make it work, we should start with an example that uses the right pair of functions. I suggest that Axes.inset_axes and Axes.indicate_inset_zoom would be the better ones to work with since they are newer, in the main Matplotlib package, and have had recent active development.

Thanks, unfortunately the version with the right inset_axes still doesn't work (hope I'm using it correctly, otherwise do let me know how I can modify the example)

map_proj = ccrs.TransverseMercator(
        )
fig, ax = plt.subplots(
    figsize=(15, 15),
    subplot_kw={
        "projection": map_proj
    },
)
ax.set_extent([-50, 15, 50, 70], crs=ccrs.PlateCarree())
ax.add_feature(cfeature.OCEAN.with_scale('50m'), facecolor="lightsteelblue", zorder=1)
ax.coastlines(linewidth=0.2, zorder=2)
inset_ax = ax.inset_axes(
    (0.05, 0.05, 0.3, 0.3),
    projection=map_proj
)
inset_extent = [-44, -38, 63, 66] 
inset_ax.set_extent(inset_extent, crs=ccrs.PlateCarree())
inset_ax.add_feature(cfeature.OCEAN, facecolor="lightsteelblue", zorder=1)
x = [inset_extent[0], inset_extent[1], inset_extent[1], inset_extent[0], inset_extent[0]]
y = [inset_extent[2], inset_extent[2], inset_extent[3], inset_extent[3], inset_extent[2]]
ax.plot(x, y, color='k', alpha=0.5, transform=ccrs.PlateCarree())
# # Draw lines between inset map and box on main map
rect, connectors = ax.indicate_inset_zoom(inset_ax, edgecolor="black", alpha=0.5, transform=ax.transAxes)

output

I just tried to remove the the transform from the indicate_inset_zoom and I get this hybrid behaviour. I think in the first plot matplotlib is trying to connect some vertices of the non-transformed bounding box.

output

Just for context, I was using this example https://predictablysunny.com/posts/inset_map_cartopy/ which was also using the mpl_toolkits version

@rcomer
Copy link
Member

rcomer commented Nov 22, 2024

I just tried to remove the the transform from the indicate_inset_zoom and I get this hybrid behaviour. I think in the first plot matplotlib is trying to connect some vertices of the non-transformed bounding box.

Actually I think this is the correct behaviour: since both your main axes and your inset axes are in the same projection, the indicator box should not be transformed. The indicator box is showing the actual extent of the inset axes, which encompasses (but does not match) what you set with set_extent. That may be more obvious if you repeat the call to plot in the inset axes.

@rcomer
Copy link
Member

rcomer commented Nov 22, 2024

With a few tweaks in Matplotlib, we can have more interesting combinations matplotlib/matplotlib#29174

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants