Skip to content

fix(graphics): axes_logic uses an empty current figure instead of creating a second one - #265

Open
petercorke wants to merge 1 commit into
rai-opensource:masterfrom
petercorke:fix/axes-logic-reuse-empty-figure
Open

petercorke wants to merge 1 commit into
rai-opensource:masterfrom
petercorke:fix/axes-logic-reuse-empty-figure

Conversation

@petercorke

Copy link
Copy Markdown
Collaborator

axes_logic reuses the current axes when the current figure has axes. When the current figure has none, as after a bare plt.figure(), it calls plt.figure() again, so the familiar plt.figure() followed by a plot_xxx() call leaves an empty figure behind. This is most visible with the ipympl backend in notebooks, where every figure stays open.

This puts the axes in the empty current figure instead. new=True still always makes a new figure, a dimension mismatch still makes a new figure, and a figure that has axes is reused as before.

There were no direct tests of axes_logic, so this adds 10: the existing behaviour and the empty-figure cases. Three fail without the change and all pass with it. Existing graphics and pose tests are unchanged.

🤖 Generated with Claude Code

…ating a second one

axes_logic reuses the current axes when the current figure has axes, but when
the current figure had none, as after a bare plt.figure(), it called
plt.figure() again.  Every "new plot" idiom (plt.figure() followed by a plot_xxx
call) therefore left an empty figure behind, most visible with the ipympl
backend where figures stay open in notebooks.

Put the axes in the empty current figure instead.  new=True still always makes a
new figure, a dimension mismatch still makes a new figure, and a current figure
that has axes is reused as before.

Add direct tests of axes_logic (there were none): the existing behaviour, and the
empty-current-figure cases.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

This branch has not been deployed

No deployments
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