问题
I'd like to create publication quality tables for output as svg or jpg or png images using python.
I'm familiar with the texttable module which produces nice text tables but if I have for example
data = [['Head 1','Head 2','Head 3'],['Sample Set Type 1',12.8,True],['Sample Set Type 2',15.7,False]]
and I wanted to produce something that looked like

Is there a module I can turn to, or can you point me to a process for going about it?
回答1:
Feels like a job for http://matplotlib.org/, as per https://stackoverflow.com/a/8976359/447599.
Could also be a job for ReportLab, as per Python reportlab inserting image into table
The other option would be to output latex source with tabular as per http://en.wikibooks.org/wiki/LaTeX/Tables
If that doesn't suit you, just write .csv files and format the table in excel, and export the image form there, with code like
with open("example.csv") as of:
for row in data:
for cell in row:
of.write(cell + ";")
of.write("\n")
I guess you could also just write an html table file and style it with css.
with open("example.html") as of:
of.write("<html><table>")
for index, row in enumerate(data):
if index == 0:
of.write("<th>")
else:
of.write("<tr>")
for cell in row:
of.write("<td>" + cell + "</td>")
if index == 0:
of.write("</th>")
else:
of.write("</tr>")
of.write("</table></html>")
来源:https://stackoverflow.com/questions/18710178/creating-publication-quality-tables-in-python