Skip to content

Instantly share code, notes, and snippets.

@kokardy
Created July 10, 2013 16:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kokardy/5967661 to your computer and use it in GitHub Desktop.
Save kokardy/5967661 to your computer and use it in GitHub Desktop.
How to use reportlab.platypus.Image with PNG that is created by matplotlib.pyplot.save_figure function
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment