Repository navigation
feat: add text_style to plot_labelbox, and make the label background follow the box edge color - #273
Merged
Merged
Conversation
…follow the box edge color The label text could only be given a color, and the label background took the color option of the box, so edgecolor= or ec= left it yellow. Add text_style (Matplotlib text options, merged with short names converted), make position, textcolor and labelcolor explicit arguments of Blobs.plot_labelbox, and take the default background from the final edge color of the box. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 16 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
text_styleargument toplot_labelboxandBlobs.plot_labelbox, and fixes the label background not following the edge color of the box. It follows the<thing>_styleconvention in rvc-ecosystem Issue 15 (open) and is item 36 of the same style work as PR 269 (merged).text_style. The label could only be given a color, and its font was not settable at all, though the docstring said the label font is "specified using the same arguments as forplot_text".text_styleis a dict of Matplotlib text options (dict(fontsize=12, fontweight="bold")). Short names are accepted (size,c,weight), as the label is merged throughmpl_styling(..., artist=Text)from PR 266. Abboxdict in it is merged over the default borderless background, so a border or rounded corners can be added.The box stays on
fmtand**kwargsas before, so existing calls are unchanged.Blobs.plot_labelboxnow hasposition,textcolor,labelcolorandtext_styleas explicit keyword-only arguments;position,textcolorandlabelcoloralready worked, by passing through**kwargs.Three sources for the text color and the background. The most specific one wins:
text_stylecolorbackgroundcolor, or thefacecolorofbboxtextcolorlabelcolorThe shorthands stay because
draw_labelbox(the OpenCV twin) has them, and they are the simple form to read in the book. This is documented in both docstrings.Bug fixed. The default background used to be the
coloroption of the box only. Withedgecolor="red"orec="red"the box turned red and the label stayed yellow. It is now the final edge color of the box, however it was set (color,edgecolor,ecor the format string).positionnow raisesValueErrorfor an unknown value; before, it failed withUnboundLocalError... versionchanged:: 2.5.0is added to both docstrings.Tests: 11 new in
tests/test_image_blobs.py: the default, the background followingcolor,edgecolor,ecand the format string, the shorthands,text_style, short names, precedence, a mergedbbox,position, the badposition, and that the caller's dict is not changed. 6 tests and 2 subtests fail on the old code. mypy reports no issues and the full suite passes (2289 passed, 30 skipped).AI-assisted: written with Claude Code (Claude Sonnet 5.5) and reviewed by the maintainer.
🤖 Generated with Claude Code