From 8b9a22b02ebd53c81b7cd9fb870e2e5377d44beb Mon Sep 17 00:00:00 2001 From: cvanelteren Date: Tue, 28 Oct 2025 09:46:13 +0100 Subject: [PATCH 1/2] minor update in sharing logic --- ultraplot/tests/test_subplots.py | 47 ++++++++++++++++++++++++++++++++ ultraplot/utils.py | 2 +- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/ultraplot/tests/test_subplots.py b/ultraplot/tests/test_subplots.py index 13b402951..487eaf166 100644 --- a/ultraplot/tests/test_subplots.py +++ b/ultraplot/tests/test_subplots.py @@ -3,6 +3,7 @@ Test subplot layout. """ import numpy as np, ultraplot as uplt, pytest +from numpy._typing import _32Bit @pytest.mark.mpl_image_compare @@ -631,3 +632,49 @@ def test_right_panel_and_right_colorbar_border_priority(): assert axi not in right_borders # Either the panel or the colorbar axes should be recognized as a right border assert (pax in right_borders) or (cbar.ax in right_borders) + + +@pytest.mark.mpl_image_compare +def test_grid_geo_and_cartesian(): + """ + Check that sharing geo and cartesian axes in a grid works. + For a grid like + + | 1 | 2 | + | 3 | 4 | + We expect the 2nd plot to be a bottom edge and 4 too if 4 is a geo axes. + """ + + layout = [[1, 2], [3, 4]] + fig, axs = uplt.subplots(layout, proj=(None, None, None, "cyl")) + axs[-1].format( + land=True, + ocean=True, + landcolor="green", + oceancolor="ocean blue", + title="Cylindrical Projection", + lonlabels=True, + latlabels=True, + grid=0, + ) + outer_axes = fig._get_border_axes() + assert axs[0] in outer_axes["top"] + assert axs[1] in outer_axes["top"] + assert axs[2] not in outer_axes["top"] + assert axs[3] in outer_axes["top"] + + assert axs[0] not in outer_axes["bottom"] + assert axs[1] in outer_axes["bottom"] + assert axs[2] in outer_axes["bottom"] + assert axs[3] in outer_axes["bottom"] + + assert axs[0] in outer_axes["left"] + assert axs[1] not in outer_axes["left"] + assert axs[2] in outer_axes["left"] + assert axs[3] in outer_axes["left"] + + assert axs[0] not in outer_axes["right"] + assert axs[1] in outer_axes["right"] + assert axs[2] in outer_axes["right"] + assert axs[3] in outer_axes["right"] + return fig diff --git a/ultraplot/utils.py b/ultraplot/utils.py index 4c5c3ea8c..ed70d9cd9 100644 --- a/ultraplot/utils.py +++ b/ultraplot/utils.py @@ -1054,7 +1054,7 @@ def is_border( return self._check_ranges(direction, other=cell) if getattr(cell, "_panel_parent", None) is self.ax: return self._check_ranges(direction, other=cell) - return False + return True # Internal edge or plot reached if cell != self.ax: From 2885aeffc06d7d6860eb49fd94eb18dbbbcd0908 Mon Sep 17 00:00:00 2001 From: cvanelteren Date: Tue, 28 Oct 2025 09:47:46 +0100 Subject: [PATCH 2/2] rm import added by editor --- ultraplot/tests/test_subplots.py | 1 - 1 file changed, 1 deletion(-) diff --git a/ultraplot/tests/test_subplots.py b/ultraplot/tests/test_subplots.py index 487eaf166..3ebe5f37d 100644 --- a/ultraplot/tests/test_subplots.py +++ b/ultraplot/tests/test_subplots.py @@ -3,7 +3,6 @@ Test subplot layout. """ import numpy as np, ultraplot as uplt, pytest -from numpy._typing import _32Bit @pytest.mark.mpl_image_compare