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

Method grab_frame

lib/matplotlib/animation.py:494–507  ·  view source on GitHub ↗
(self, **savefig_kwargs)

Source from the content-addressed store, hash-verified

492 self._frames = []
493
494 def grab_frame(self, **savefig_kwargs):
495 _validate_grabframe_kwargs(savefig_kwargs)
496 buf = BytesIO()
497 self.fig.savefig(
498 buf, **{**savefig_kwargs, "format": "rgba", "dpi": self.dpi})
499 im = Image.frombuffer(
500 "RGBA", self.frame_size, buf.getbuffer(), "raw", "RGBA", 0, 1)
501 if im.getextrema()[3][0] < 255:
502 # This frame has transparency, so we'll just add it as is.
503 self._frames.append(im)
504 else:
505 # Without transparency, we switch to RGB mode, which converts to P mode a
506 # little better if needed (specifically, this helps with GIF output.)
507 self._frames.append(im.convert("RGB"))
508
509 def finish(self):
510 self._frames[0].save(

Callers 1

Calls 3

savefigMethod · 0.45
convertMethod · 0.45

Tested by 1