Skip to content

fix: Blobs.plot_labelbox and plot_box say when a format string has a marker - #270

Merged
petercorke merged 2 commits into
mainfrom
bug/blobs-plot-labelbox-fmt
Nov 23, 2026
Merged

petercorke merged 2 commits into
mainfrom
bug/blobs-plot-labelbox-fmt

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Fixes Blobs.plot_labelbox("o") failing with ValueError: Unrecognized linestyle: 'o', and gives a clear error when a format string has a marker for a box. Found while working on the format-string parser (PR 267, merged).

The cause. Blobs.plot_labelbox turned the format string into options with mpl_styling and also passed the raw string on to the base plot_labelbox, which hands it to spatialmath's plot_box. That function sorts the characters by hand, and put "o" into the line style. Strings with only a color and a line style ("r--", "g") worked, because both paths agreed.

The change.

  • Blobs.plot_labelbox passes the options once, and no longer passes the string a second time.
  • mpl_styling refuses a marker in the format string when the artist is a Patch, because a box cannot draw one: plot_box("r.") and plot_labelbox("o") now say format string 'r.' has a marker, which a Patch cannot draw. Before, plot_box("o") failed inside Matplotlib with Rectangle.set() got an unexpected keyword argument 'marker'.
  • The three plot_box tests that were skipped ("positional fmt argument is broken, upstream PR pending") pass, so I re-enabled them. The cause was fixed in spatialmath some time ago.

Tests. A box is drawn with the right edge color and line style for "r--", "g", "C1:", "orange" and "--" (which keeps the default yellow), for both methods; a marker gives the new error for both; plot_labelbox has a count test; and mpl_styling has a test of the new check. mypy reports no issues and the full suite passes (2267 passed, 30 skipped).

AI-assisted: written with Claude Code (Claude Sonnet 5.5) and reviewed by the maintainer.

🤖 Generated with Claude Code

…marker

plot_labelbox handed its format string to the base function as well as in the
options, so plot_labelbox('o') failed with 'Unrecognized linestyle', and a
marker on a box failed inside Matplotlib. Pass the options only once, and make
mpl_styling refuse a marker when the artist is a Patch. Re-enable the plot_box
tests that were skipped.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 8 complexity · 0 duplication

Metric Results
Complexity 8
Duplication 0

View in Codacy

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.

@petercorke
petercorke merged commit bb4db62 into main Nov 23, 2026
32 checks passed
@petercorke
petercorke deleted the bug/blobs-plot-labelbox-fmt branch November 23, 2026 21:20
@github-actions github-actions Bot mentioned this pull request Nov 23, 2026
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