Skip to content

Commit aca3f93

Browse files
iangowclaude
andcommitted
Fix theta_label_pad being overwritten by facet margin padding
facet.set_limits_breaks_and_labels() called ax.tick_params(axis='x', pad=pad_x) after coord.draw(), silently overwriting any custom theta_label_pad set by coord_radial. Add a post_setup_ax() hook to the coord base class, called by set_limits_breaks_and_labels after the margin pad, so coord_radial can apply theta_label_pad at the correct point in the rendering pipeline. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 9a5c752 commit aca3f93

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

plotnine/coords/coord.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ def draw(self, axs: list) -> None:
112112
add elements such as polar grid lines.
113113
"""
114114

115+
def post_setup_ax(self, ax: Any) -> None:
116+
"""
117+
Hook called for each axes after set_limits_breaks_and_labels.
118+
119+
Override in subclasses to apply per-axes settings that must
120+
run after the facet has set tick positions and label padding.
121+
"""
122+
115123
def labels(self, cur_labels: labels_view) -> labels_view:
116124
"""
117125
Modify labels

plotnine/coords/coord_radial.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def draw(self, axs: list[Axes]) -> None:
254254
else:
255255
ax.set_rlabel_position(np.degrees(float(self.r_axis_inside)))
256256

257-
# Push theta tick labels away from the outer circle so they don't
258-
# sit right on the spine.
259-
if self.theta_labels or self.end is not None:
260-
ax.tick_params(axis="x", pad=self.theta_label_pad)
257+
def post_setup_ax(self, ax: Axes) -> None:
258+
"""Apply theta label pad after facet has set tick positions and padding."""
259+
if self.theta_labels or self.end is not None:
260+
ax.tick_params(axis="x", pad=self.theta_label_pad)

plotnine/facets/facet.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ def _inf_to_none(
355355

356356
ax.tick_params(axis="x", which="major", pad=pad_x)
357357
ax.tick_params(axis="y", which="major", pad=pad_y)
358+
self.coordinates.post_setup_ax(ax)
358359

359360
def __deepcopy__(self, memo: dict[Any, Any]) -> facet:
360361
"""

0 commit comments

Comments
 (0)