feat(pl): add angle_range parameter for polar pie-slice trees#51
feat(pl): add angle_range parameter for polar pie-slice trees#51
Conversation
…r pie-slice trees Add an `angle_range=(start, end)` tuple parameter (in degrees) to `pl.branches()` and `pl.tree()` so users can plot polar trees that span a subset of the circle (e.g. a semicircle or quarter-circle) rather than always using the full 360 degrees. - `layout_trees()` now accepts `start_angle`/`end_angle` (radians) and distributes leaves across that arc instead of always [0, 2π] - `branches()` converts the degree tuple to radians, passes it through, and stores the angles in `ax._attrs` for downstream consumers - `annotation()` reads `start_angle`/`end_angle` from `ax._attrs` so annotation rings align with partial-arc trees - `tree()` accepts and forwards `angle_range` to `branches()` Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #51 +/- ##
==========================================
+ Coverage 92.89% 92.91% +0.01%
==========================================
Files 34 34
Lines 2549 2554 +5
==========================================
+ Hits 2368 2373 +5
Misses 181 181
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5ba3de39a2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| start_angle_rad = np.deg2rad(angle_range[0]) | ||
| end_angle_rad = np.deg2rad(angle_range[1]) |
There was a problem hiding this comment.
Constrain polar axes to the requested angle span
When polar=True and angle_range is smaller than 360°, this change only remaps the branch coordinates; branches() never applies set_thetamin/set_thetamax (or equivalent) to the polar axes. In Matplotlib that still renders a full 360° polar frame, so the new semicircle/quarter-circle modes produce mostly empty circular plots instead of the advertised pie-slice trees.
Useful? React with 👍 / 👎.
| polar=polar, | ||
| extend_branches=extend_branches, | ||
| angled_branches=angled_branches, | ||
| start_angle=start_angle_rad, | ||
| end_angle=end_angle_rad, |
There was a problem hiding this comment.
Skip angle_range when rendering Cartesian trees
These angles are passed into layout_trees() unconditionally, even though the new parameter is documented as 'Only used when polar=True'. If a caller reuses a config like tree(..., angle_range=(0, 180)) with polar=False, the Cartesian branch layout and any later annotation() call are compressed into that half-range because ax._attrs['start_angle'/'end_angle'] also gets populated from it.
Useful? React with 👍 / 👎.
Summary
angle_range: tuple[float, float] = (0, 360)parameter topl.branches()andpl.tree()for polar plots(start, end)arc in degrees (e.g.(0, 180)for a semicircle)annotation()automatically aligns annotation rings with the partial arc by reading stored angles fromax._attrs(0, 360)preserves existing behaviorUsage
Test plan
test_polar_angle_rangetest covers semicircle, quarter-circle, offset arc, and default (360°) casesax._attrsstores correct radian values🤖 Generated with Claude Code