LoginSignup
3
4

More than 5 years have passed since last update.

matplotlibでグラフを動的に生成して、reporlabでPDFに埋め込む

Posted at

PIL.ImageFileIOを経由するといけるっぽい。

webで動的にPDF作成して返すときに使えます。

from StringIO import StringIO
from PIL import ImageFileIO
import matplotlib.pyplot as plt
from reportlab.platypus import Image

buf = StringIO()

#plot your graphs

plt.save_figure(buf, format="png")
buf.seek(0)
im = ImageFileIO.ImageFileIO(buf)

flowable_image = Image(im) 

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4