MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / update_background

Method update_background

lib/matplotlib/widgets.py:2371–2397  ·  view source on GitHub ↗

Force an update of the background.

(self, event)

Source from the content-addressed store, hash-verified

2369 if a.get_animated() and a not in self.artists)
2370
2371 def update_background(self, event):
2372 """Force an update of the background."""
2373 # If you add a call to `ignore` here, you'll want to check edge case:
2374 # `release` can call a draw event even when `ignore` is True.
2375 if not self.useblit:
2376 return
2377 if self.canvas.is_saving():
2378 return # saving does not use blitting
2379 # Make sure that widget artists don't get accidentally included in the
2380 # background, by re-rendering the background if needed (and then
2381 # re-re-rendering the canvas with the visible widget artists).
2382 # We need to remove all artists which will be drawn when updating
2383 # the selector: if we have animated artists in the figure, it is safer
2384 # to redrawn by default, in case they have updated by the callback
2385 # zorder needs to be respected when redrawing
2386 artists = sorted(self.artists + self._get_animated_artists(),
2387 key=lambda a: a.get_zorder())
2388 needs_redraw = any(artist.get_visible() for artist in artists)
2389 with ExitStack() as stack:
2390 if needs_redraw:
2391 for artist in artists:
2392 stack.enter_context(artist._cm_set(visible=False))
2393 self.canvas.draw()
2394 self._save_blit_background(self.canvas.copy_from_bbox(self.ax.bbox))
2395 if needs_redraw:
2396 for artist in artists:
2397 self.ax.draw_artist(artist)
2398
2399 def connect_default_events(self):
2400 """Connect the major canvas events to methods."""

Callers 2

set_activeMethod · 0.95
updateMethod · 0.95

Calls 9

_get_animated_artistsMethod · 0.95
is_savingMethod · 0.80
get_zorderMethod · 0.80
_cm_setMethod · 0.80
_save_blit_backgroundMethod · 0.80
get_visibleMethod · 0.45
drawMethod · 0.45
copy_from_bboxMethod · 0.45
draw_artistMethod · 0.45

Tested by

no test coverage detected