Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions ultraplot/tests/test_subplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,3 +631,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
2 changes: 1 addition & 1 deletion ultraplot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down