Skip to content

Honor authored plot and text styles [codex bughunt] - #351

Merged
sselvakumaran merged 2 commits into
agent/gallery-layout-text-round2from
agent/bughunt-authored-style-parity
Jul 28, 2026
Merged

Honor authored plot and text styles [codex bughunt]#351
sselvakumaran merged 2 commits into
agent/gallery-layout-text-round2from
agent/bughunt-authored-style-parity

Conversation

@sselvakumaran

@sselvakumaran sselvakumaran commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

This is the first bug-hunt PR stacked directly on #340 (agent/gallery-layout-text-round2). It fixes a coherent set of cases where user-authored styling was accepted but lost, mutated, or exported inconsistently.

Bar and errorbar styling

  • route bar() / barh() error geometry through the shim's canonical errorbar() path;
  • preserve ecolor, elinewidth / linewidth, and point-sized caps;
  • match Matplotlib's error_kw precedence over direct bar arguments;
  • copy caller-owned error_kw mappings instead of mutating them;
  • register the ErrorbarContainer before the BarContainer, preserve public labels, and keep the default _nolegend_ label out of rendered automatic legends;
  • preserve Matplotlib container order when both the uncertainty and bar series are explicitly labeled.

Text and axis labels

  • forward numeric, "vertical", and "horizontal" axis-label rotations with the renderer-coordinate sign Matplotlib expects;
  • distinguish omitted rotation from explicit rotation=None, so omission preserves prior state and None resets it;
  • add text.color="white" to dark_background;
  • snapshot default text paint when axes text, annotations, figure text, and suptitles are authored, so later style-context changes cannot recolor them;
  • treat suptitle(color=None) like the Matplotlib default and preserve explicit overrides.

SVG marker paint

  • apply annotation-marker opacity to both fill and stroke; previously a translucent marker could retain a fully opaque outline.

Why

These were fidelity bugs rather than palette differences: valid Matplotlib inputs were silently discarded, a caller-owned mapping was modified, dark-background labels became unreadable when exported after leaving a style context, a private _nolegend_ label leaked into the visible chart, and SVG fill/stroke opacity disagreed.

Visual comparisons

Review-only artifacts live on immutable evidence commit 15620da82939f25be38c53a174f819a027b1c0dc; they are not in this PR diff.

Matplotlib / XY before / XY after

Authored bar error, text, annotation, and rotation styles

The same script now preserves red error bars and width, visible dark-theme text/annotation defaults, and the authored x-label rotation. The comparison uses an explicit labelpad so it demonstrates rotation forwarding without conflating the separate general rotated-label-layout issue.

SVG marker opacity

Marker stroke opacity before and after

Before, opacity=0.22 affected the purple fill but left the cyan outline opaque. After, both paints honor the authored alpha.

Verification

  • 143 passed across the focused and adjacent bar/errorbar, legend, text/theme, artist-state, chrome, and exporter regressions;
  • a separate 92 passed SVG, figure-text, and multiline-layout exporter pass;
  • full-worktree Ruff lint and format: 437 files clean;
  • repository pre-commit hooks: Ruff check, Ruff format, and docs codespell all passed;
  • git diff --check passed;
  • independent final review found no remaining blocker in this PR scope.

No browser or Playwright process was launched locally. No compatibility ledger, changelog, shim-todo, docs spec, or PR asset file is part of the product diff.

Explicitly deferred

The existing compact public capline artist graph is not changed here. A partial two/four-capline repair was rejected during review because mixed xerr + yerr and limit-carets also require correct Line2D ordering and one barline collection per error axis. That broader public-artist repair should land as a complete later stack layer rather than a misleading partial fix.

Summary by CodeRabbit

  • Bug Fixes
    • SVG annotation markers now apply opacity consistently to both fills and strokes.
    • Dark-background plots now render default text in white while preserving explicitly chosen colors.
    • Improved compatibility for error bars, legends, labels, and error styling.
    • Text and axis-label colors and rotations now behave consistently with Matplotlib, including delayed exports.
  • Tests
    • Added regression coverage for marker opacity, dark-background text, error bars, legends, and label rotation.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@sselvakumaran, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 10 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 932c1b2d-170d-4fb4-93dc-c363bcaa4528

📥 Commits

Reviewing files that changed from the base of the PR and between 231ee52 and 59f07bb.

📒 Files selected for processing (10)
  • python/xy/_svg.py
  • python/xy/pyplot/__init__.py
  • python/xy/pyplot/_artists.py
  • python/xy/pyplot/_axes.py
  • python/xy/pyplot/_mplfig.py
  • python/xy/pyplot/_plot_types.py
  • tests/pyplot/test_bughunt_authored_style_parity.py
  • tests/pyplot/test_dark_background_text_parity.py
  • tests/pyplot/test_gallery_text_pie_compat.py
  • tests/test_svg_annotation_marker_opacity.py
📝 Walkthrough

Walkthrough

Updates Matplotlib-compatible text color and rotation handling, refactors bar errorbar containers and legend semantics, and adds SVG marker stroke opacity support with regression tests.

Changes

Text styling parity

Layer / File(s) Summary
Text defaults and rotation
python/xy/pyplot/__init__.py, python/xy/pyplot/_axes.py, python/xy/pyplot/_mplfig.py, tests/pyplot/test_dark_background_text_parity.py, tests/pyplot/test_gallery_text_pie_compat.py, tests/pyplot/test_bughunt_authored_style_parity.py
Text colors now snapshot active defaults, dark-background text defaults to white, suptitles use the active text color, and axis-label rotation supports numeric, named, and reset values.

Bar errorbar parity

Layer / File(s) Summary
Bar errorbar and legend flow
python/xy/pyplot/_axes.py, python/xy/pyplot/_artists.py, python/xy/pyplot/_plot_types.py, tests/pyplot/test_bughunt_authored_style_parity.py
Bar error options are validated and copied, errorbars are created through Axes.errorbar(), private container labels are suppressed from rendering, and legend ordering follows container semantics.

SVG marker opacity

Layer / File(s) Summary
Marker stroke opacity rendering
python/xy/_svg.py, tests/test_svg_annotation_marker_opacity.py
Translucent annotation markers now emit stroke-opacity, with SVG tests covering opaque and non-opaque markers.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Suggested reviewers: alek99

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.17% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main theme of preserving authored plot and text styling.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/bughunt-authored-style-parity

Comment @coderabbitai help to get the list of available commands.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@codspeed-hq

codspeed-hq Bot commented Jul 27, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 103 untouched benchmarks
⏩ 2 skipped benchmarks1


Comparing agent/bughunt-authored-style-parity (59f07bb) with agent/gallery-layout-text-round2 (b87ab3b)

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@python/xy/pyplot/_artists.py`:
- Around line 999-1002: Update ErrorbarContainer.set_label so a None value
remains None instead of being converted to the string "None". Preserve string
conversion for non-None values, and ensure both _mpl_container_label and
kwargs["name"] use the cleared None value appropriately.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c57bc18f-743d-4c23-bf5c-01560cf958fa

📥 Commits

Reviewing files that changed from the base of the PR and between 2a7d6eb and 231ee52.

📒 Files selected for processing (10)
  • python/xy/_svg.py
  • python/xy/pyplot/__init__.py
  • python/xy/pyplot/_artists.py
  • python/xy/pyplot/_axes.py
  • python/xy/pyplot/_mplfig.py
  • python/xy/pyplot/_plot_types.py
  • tests/pyplot/test_bughunt_authored_style_parity.py
  • tests/pyplot/test_dark_background_text_parity.py
  • tests/pyplot/test_gallery_text_pie_compat.py
  • tests/test_svg_annotation_marker_opacity.py

Comment thread python/xy/pyplot/_artists.py Outdated
@sselvakumaran
sselvakumaran force-pushed the agent/bughunt-authored-style-parity branch from 01a2482 to 59f07bb Compare July 28, 2026 00:02

Copy link
Copy Markdown
Contributor Author

Restacked cleanly onto the updated #340 head; the PR-relative stable patch ID is unchanged. Full repository hooks, Ruff, formatting, and git diff --check pass on the rebased tree.

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

The PR description image shows the bar-chart comparison: “XY after” restores the solid, authored bar styling relative to “XY before”, while retaining the red error bars and readable “notes stay visible” / “peak” annotations. It also shows the opacity comparison where “XY after — alpha on fill + outline” makes the cyan ring translucent on both its fill and stroke, matching the displayed alpha=0.22 applies to fill and outline text.

@sselvakumaran: Acknowledged—the clean restack and unchanged PR-relative patch identity are noted. Triggering a review of the current PR head.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@sselvakumaran
sselvakumaran merged commit 59f07bb into main Jul 28, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant