from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, Image
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.lib.units import inch
import matplotlib.pyplot as plt
# create a plot
plt.plot([1,2,3],[2,4,6])
plt.title("Amplification")
plt.savefig("plot.png")
plt.close()
styles = getSampleStyleSheet()
data = [
["Unknown 1", "Unknown 2", "ΔCq"],
["3.71", "3.54", "0.17"]
]
table = Table(data)
elements = [
Paragraph("CFX Qualification Plate Report", styles['Title']),
Spacer(1,20),
table,
Spacer(1,20),
Image("plot.png", width=5*inch, height=3*inch)
]
doc = SimpleDocTemplate("report.pdf")
doc.build(elements) Click Run or press shift + ENTER to run code