Skip to content

Feature/legend title kw clean#657

Draft
cvanelteren wants to merge 3 commits intomainfrom
feature/legend-title-kw-clean
Draft

Feature/legend title kw clean#657
cvanelteren wants to merge 3 commits intomainfrom
feature/legend-title-kw-clean

Conversation

@cvanelteren
Copy link
Collaborator

Somehow this was not implemented.

Continuation of #656 after messing with claude a bit (new to it).

The legend API now accepts a title_kw dict for passing arbitrary Text
properties to the legend title (e.g. title_kw={'style': 'italic'}),
consistent with the existing handle_kw parameter for handle styling.
This change also fixes a pre-existing bug where titlefontweight and
titlefontcolor were accepted by the API and silently stored but never
actually applied to the legend title Text object — they now take effect
as expected.
@codecov
Copy link

codecov bot commented Mar 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@cvanelteren
Copy link
Collaborator Author

Regression is not related to the PR. I will need to think if this is a correct fixas we do list this property in the docs but it did not exist since ProPlot times. I ran into this problem when wanting to align the title, but this can be achieved through align

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Implements support for passing arbitrary matplotlib.text.Text properties to the legend title via a new title_kw keyword, completing the intended feature from #656 and adding tests/docs to lock in the behavior.

Changes:

  • Add title_kw plumbing through legend input resolution and style application so title text properties can be set/overridden.
  • Ensure title_kw overrides titlefontweight/titlefontcolor when both are provided (merge order).
  • Add unit tests and update legend-parameter documentation to cover title_kw.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
ultraplot/legend.py Adds title_kw to normalized inputs and applies merged title text styling to legend titles.
ultraplot/axes/base.py Documents title_kw and forwards it through _add_legend to the legend implementation.
ultraplot/tests/test_legend.py Adds focused tests validating title_kw behavior and override precedence vs. titlefont*.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants