Skip to content

swev-id: matplotlib__matplotlib-24637: Propagate gid for AnnotationBbox via renderer group (Task 272)#48

Open
casey-brooks wants to merge 1 commit intomatplotlib__matplotlib-24637from
fix-annotationbbox-gid-272
Open

swev-id: matplotlib__matplotlib-24637: Propagate gid for AnnotationBbox via renderer group (Task 272)#48
casey-brooks wants to merge 1 commit intomatplotlib__matplotlib-24637from
fix-annotationbbox-gid-272

Conversation

@casey-brooks
Copy link

Summary

  • wrap AnnotationBbox.draw in a renderer group so gid propagates to backends
  • close the renderer group after drawing the arrow, patch, and offsetbox content
  • add an SVG regression test asserting <g id> emission for AnnotationBbox

Reproduction

Before

  1. Create an AnnotationBbox with a gid, save the figure as SVG, and inspect the markup.
  2. The annotation renders without an enclosing <g id="...">, so downstream selection fails.

After

  1. Repeat the steps above.
  2. The SVG output now contains <g id="ab_gid_test"> wrapping the annotation content.

Testing

  • LD_LIBRARY_PATH=/root/.nix-profile/lib:/nix/store/wffgswxkp55xi14jy63rjsnfvl2qvmxy-gcc-14.3.0-lib/lib MPLBACKEND=Agg .venv/bin/pytest lib/matplotlib/tests/test_backend_svg.py::test_annotationbbox_gid_svg

Fixes #44

@casey-brooks casey-brooks requested a review from a team December 25, 2025 11:58
@casey-brooks
Copy link
Author

Test & Lint Summary

  • LD_LIBRARY_PATH=/root/.nix-profile/lib:/nix/store/wffgswxkp55xi14jy63rjsnfvl2qvmxy-gcc-14.3.0-lib/lib MPLBACKEND=Agg .venv/bin/pytest lib/matplotlib/tests/test_backend_svg.py::test_annotationbbox_gid_svg — 1 passed, 0 failed, 0 skipped (pyparsing emitted the known sre_constants DeprecationWarning)
  • .venv/bin/flake8 lib/matplotlib/offsetbox.py lib/matplotlib/tests/test_backend_svg.py — no issues detected

Copy link

@noa-lucent noa-lucent left a comment

Choose a reason for hiding this comment

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

The renderer group wrapper cleanly propagates the AnnotationBbox gid to SVG (and other group-aware backends), and the new regression test verifies the emitted . Thanks!

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