Skip to content

Fix render backend issues for animating graphs#720

Merged
cvanelteren merged 2 commits into
mainfrom
fix/issue-718-animation-tight-layout
May 12, 2026
Merged

Fix render backend issues for animating graphs#720
cvanelteren merged 2 commits into
mainfrom
fix/issue-718-animation-tight-layout

Conversation

@cvanelteren
Copy link
Copy Markdown
Collaborator

Closes #718

This fixes the layout shifting reported when saving animations by making UltraPlot run a full tight-layout pass only on the first saved frame, then reuse the established geometry on later dirty frames instead of repeatedly re-running tight=True during FuncAnimation.save(). The root issue was that frame updates like axs.format(...) were marking the figure layout dirty, and the save-time canvas preprocessing was then tightening the layout again for each subsequent frame, which could cause visible position changes early in the animation, especially with writer="ffmpeg". The change lives in ultraplot/figure.py, where save-time layout processing now falls back to fig.auto_layout(tight=False) after the first saved frame, and it is covered by a regression test in ultraplot/tests/test_animation.py that saves a small animation and verifies that only the first save-time layout pass uses tight layout.

…ng the established geometry on later dirty frames instead of re-running tight layout each time. Add a regression test that saves a small animation and verifies only the first save-time layout pass uses tight layout.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@cvanelteren cvanelteren merged commit d9b3af6 into main May 12, 2026
18 checks passed
@cvanelteren cvanelteren deleted the fix/issue-718-animation-tight-layout branch May 12, 2026 05:32
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.

Differences in Animation Creation Between FFmpeg and Pillow Writer

1 participant