Skip to content

Commit 7263c01

Browse files
authored
Hotfix: minor update in sharing logic (#387)
* minor update in sharing logic * rm import added by editor
1 parent 4078a93 commit 7263c01

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

ultraplot/tests/test_subplots.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,3 +631,49 @@ def test_right_panel_and_right_colorbar_border_priority():
631631
assert axi not in right_borders
632632
# Either the panel or the colorbar axes should be recognized as a right border
633633
assert (pax in right_borders) or (cbar.ax in right_borders)
634+
635+
636+
@pytest.mark.mpl_image_compare
637+
def test_grid_geo_and_cartesian():
638+
"""
639+
Check that sharing geo and cartesian axes in a grid works.
640+
For a grid like
641+
642+
| 1 | 2 |
643+
| 3 | 4 |
644+
We expect the 2nd plot to be a bottom edge and 4 too if 4 is a geo axes.
645+
"""
646+
647+
layout = [[1, 2], [3, 4]]
648+
fig, axs = uplt.subplots(layout, proj=(None, None, None, "cyl"))
649+
axs[-1].format(
650+
land=True,
651+
ocean=True,
652+
landcolor="green",
653+
oceancolor="ocean blue",
654+
title="Cylindrical Projection",
655+
lonlabels=True,
656+
latlabels=True,
657+
grid=0,
658+
)
659+
outer_axes = fig._get_border_axes()
660+
assert axs[0] in outer_axes["top"]
661+
assert axs[1] in outer_axes["top"]
662+
assert axs[2] not in outer_axes["top"]
663+
assert axs[3] in outer_axes["top"]
664+
665+
assert axs[0] not in outer_axes["bottom"]
666+
assert axs[1] in outer_axes["bottom"]
667+
assert axs[2] in outer_axes["bottom"]
668+
assert axs[3] in outer_axes["bottom"]
669+
670+
assert axs[0] in outer_axes["left"]
671+
assert axs[1] not in outer_axes["left"]
672+
assert axs[2] in outer_axes["left"]
673+
assert axs[3] in outer_axes["left"]
674+
675+
assert axs[0] not in outer_axes["right"]
676+
assert axs[1] in outer_axes["right"]
677+
assert axs[2] in outer_axes["right"]
678+
assert axs[3] in outer_axes["right"]
679+
return fig

ultraplot/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ def is_border(
10541054
return self._check_ranges(direction, other=cell)
10551055
if getattr(cell, "_panel_parent", None) is self.ax:
10561056
return self._check_ranges(direction, other=cell)
1057-
return False
1057+
return True
10581058

10591059
# Internal edge or plot reached
10601060
if cell != self.ax:

0 commit comments

Comments
 (0)