【发布时间】:2012-07-04 22:48:14
【问题描述】:
绘图模块
def plotGraph(X,Y):
fignum = random.randint(0,sys.maxint)
plt.figure(fignum)
### Plotting arrangements ###
return fignum
主模块
import matplotlib.pyplot as plt
### tempDLStats, tempDLlabels are the argument
plot1 = plotGraph(tempDLstats, tempDLlabels)
plot2 = plotGraph(tempDLstats_1, tempDLlabels_1)
plot3 = plotGraph(tempDLstats_2, tempDLlabels_2)
plt.show()
我想将所有图形 plot1、plot2、plot3 保存到一个 PDF 文件中。有没有办法实现它?我不能在主模块中包含plotGraph 函数。
有一个名为pyplot.savefig 的函数,但它似乎只适用于单个数字。有没有其他方法可以实现?
【问题讨论】:
-
我在这里为基本上相同的问题提供了一个解决方案:stackoverflow.com/questions/38938454/… 仅供参考;它可能很有趣,提供多功能模板代码,其中包含许多演示自定义每页子图的数量、它们之间的间距、整体样式等,使用来自
matplotlib的 PdfPages 和可选的更高级的代码模板,利用seaborn
标签: python matplotlib