Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 396a010

Browse files
authored
Merge pull request #22175 from greglucas/macosx-animations
FIX: Update macosx animation handling
2 parents a9dd8b9 + 29dad01 commit 396a010

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/matplotlib/animation.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1185,9 +1185,16 @@ def _setup_blit(self):
11851185
# Setting up the blit requires: a cache of the background for the Axes
11861186
self._blit_cache = dict()
11871187
self._drawn_artists = []
1188+
# _post_draw needs to be called first to initialize the renderer
1189+
self._post_draw(None, self._blit)
1190+
# Then we need to clear the Frame for the initial draw
1191+
# This is typically handled in _on_resize because QT and Tk
1192+
# emit a resize event on launch, but the macosx backend does not,
1193+
# thus we force it here for everyone for consistency
1194+
self._init_draw()
1195+
# Connect to future resize events
11881196
self._resize_id = self._fig.canvas.mpl_connect('resize_event',
11891197
self._on_resize)
1190-
self._post_draw(None, self._blit)
11911198

11921199
def _on_resize(self, event):
11931200
# On resize, we need to disable the resize event handling so we don't

src/_macosx.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,6 +1294,8 @@ - (void)updateDevicePixelRatio:(double)scale
12941294
goto exit;
12951295
}
12961296
if (PyObject_IsTrue(change)) {
1297+
// Notify that there was a resize_event that took place
1298+
gil_call_method(canvas, "resize_event");
12971299
[self setNeedsDisplay: YES];
12981300
}
12991301

0 commit comments

Comments
 (0)