Skip to content

Commit e9d95f3

Browse files
iangowclaude
andcommitted
Fix start-angle rotation hiding bars for full-circle plots
coord_polar hardcoded x limits to [0, 2π], but _to_radians maps data to [start, start+2π]. With start=3π/2 the bars from ~Oct–Mar land at theta > 2π and get clipped by the xlim. Fix by setting limits to [start, start+2π] so the data range always falls within the visible window. Remove the now-redundant break-wrapping mod-2π in coord_radial since breaks in [start, start+2π] are naturally within the new limits. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 61777e6 commit e9d95f3

2 files changed

Lines changed: 6 additions & 10 deletions

File tree

plotnine/coords/coord_polar.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,14 @@ def setup_panel_params(
8282

8383
empty = np.array([], dtype=float)
8484

85-
# x → theta axis: PolarAxes expects radians in [0, 2π]; suppress ticks
86-
# because our data ticks would be in original data units, not radians.
85+
# x → theta axis: data ticks are in original units (not radians), so
86+
# suppress them. Limits span [start, start+2π] so that bars rotated
87+
# by a non-zero start angle stay within the displayed theta range.
88+
theta_start = float(self.start)
8789
new_x = replace(
8890
pv_exp.x,
89-
limits=(0.0, 2 * np.pi),
90-
range=(0.0, 2 * np.pi),
91+
limits=(theta_start, theta_start + 2 * np.pi),
92+
range=(theta_start, theta_start + 2 * np.pi),
9193
breaks=[],
9294
minor_breaks=empty,
9395
labels=[],

plotnine/coords/coord_radial.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,6 @@ def setup_panel_params(self, scale_x: scale, scale_y: scale) -> panel_view:
160160
keep = [arc_lo <= r <= arc_hi for r in radian_pos]
161161
radian_pos = [r for r, k in zip(radian_pos, keep) if k]
162162
theta_labels = [l for l, k in zip(theta_labels, keep) if k]
163-
else:
164-
# Full circle: ax.set_xticks with negative values silently extends
165-
# xlim below 0, turning the full circle into a partial arc. Wrap
166-
# all break positions into [0, 2π] to avoid this.
167-
tau = 2.0 * np.pi
168-
radian_pos = [r % tau for r in radian_pos]
169163
x_updates["breaks"] = radian_pos
170164
x_updates["labels"] = theta_labels
171165

0 commit comments

Comments
 (0)