Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.1k
Description
Bug report
Bug summary
draw_event currently firesafter the draw has completed (it is triggered at the end of Figure.draw()). This means it cannot modify the Figure, unless one is willing to trigger a second draw -- and even then one needs to be careful to not recurse infinitely. For example, inhttps://matplotlib.org/3.1.0/gallery/pyplots/auto_subplots_adjust.html (linking the 3.1 version because there's an unrelated bug in 3.2, per#17167), note the call to figure.canvas.draw() at the end of the callback, effectively duplicating the draw(); moreover, if that draw() is moved out of theif block then one gets an infinite recursion. Being able to register a callback to be executedbefore draw() occurs would avoid both problems.
Likewise a pre-draw callback would provide a very general solution for#17052, by allowing one to simply update the colorbar at pre-draw time.
The same feature was rejected because there wasn't a compelling use case in#5042, but I think I exposed more use cases here. See also#10334 re: recursive redraws.
Matplotlib version
- Operating system:
- Matplotlib version: 3.2
- Matplotlib backend (
print(matplotlib.get_backend())): - Python version:
- Jupyter version (if applicable):
- Other libraries: