Skip to content

Commit f31158c

Browse files
authored
Keep gridline labels when updating ticklen (#520)
1 parent 3d9cb4d commit f31158c

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

ultraplot/axes/geo.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2139,6 +2139,9 @@ def _add_geoticks(self, x_or_y: str, itick: Any, ticklen: Any) -> None:
21392139
for size, which in zip(sizes, ["major", "minor"]):
21402140
params.update({"length": size})
21412141
params.pop("grid_alpha", None)
2142+
# Avoid overriding gridliner label toggles via tick_params defaults.
2143+
for key in ("labeltop", "labelbottom", "labelleft", "labelright"):
2144+
params.pop(key, None)
21422145
self.tick_params(
21432146
axis=x_or_y,
21442147
which=which,

ultraplot/tests/test_geographic.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,6 +1137,20 @@ def test_consistent_range():
11371137
assert np.allclose(latview, latlim, atol=1.0)
11381138

11391139

1140+
def test_labels_preserved_with_ticklen():
1141+
"""
1142+
Ensure ticklen updates do not disable top/right gridline labels.
1143+
"""
1144+
fig, ax = uplt.subplots(proj="cyl")
1145+
ax.format(lonlim=(0, 10), latlim=(0, 10), labels="both", lonlines=2, latlines=2)
1146+
assert ax.gridlines_major.top_labels
1147+
assert ax.gridlines_major.right_labels
1148+
1149+
ax.format(ticklen=1, labels="both")
1150+
assert ax.gridlines_major.top_labels
1151+
assert ax.gridlines_major.right_labels
1152+
1153+
11401154
@pytest.mark.mpl_image_compare
11411155
def test_dms_used_for_mercator():
11421156
"""

0 commit comments

Comments
 (0)