Skip to content

Conversation

@cvanelteren
Copy link
Collaborator

This PR adds an animation.force_draw_idle rcParam (default on) and uses it to gate a targeted FuncAnimation hook that swaps draw_idle to full draws on interactive canvases, reducing backend redraw artifacts without affecting headless renders, while keeping the earlier layout convergence work intact

Closes #488

Drafting for now as I am not happy with it yet.

This commit addresses two issues related to :
1.  Noise and streaking artifacts in animations due to unconditional  calls on every draw.
2.  A  caused by the  keyword argument being passed to Matplotlib internals.

The following changes have been made:
- A  flag has been introduced in the  class to control when  is called.
-  is now only called when the figure's layout is dirty, preventing unnecessary recalculations during animations.
- The  method in  now only resizes the figure if the new size is different, preventing small oscillations.
- The  keyword argument is now popped in  to prevent it from being passed to Matplotlib.
@cvanelteren cvanelteren marked this pull request as ready for review January 22, 2026 10:35
Copy link
Collaborator

@beckermr beckermr left a comment

Choose a reason for hiding this comment

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

Monkey patching is very fragile. Is there a cleaner way to do this?

@cvanelteren
Copy link
Collaborator Author

Well we would have to replace how the layout is drawn -- I believe the issue is coming from the fact that ultraplot does a lot of layout correction on draw which causes an issue with FuncAnimation. Another option would be to provide a FuncAnimation ourselves that patches this internally. Since we are replacing the layout algorithm in #430 we could try and fix it with a patch on that.

@beckermr
Copy link
Collaborator

I see. The less patching we do, the better. I think given the nature of the fix, we should try and solve this cleanly with the new layout handling.

@cvanelteren cvanelteren added the Wait Suspending current issue until further notice label Jan 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Wait Suspending current issue until further notice

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Points to note when creating animations using ultraplot

3 participants