——绘图模块——
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。所以,有没有办法实现它,不,我不能在mainModule中包含plotGraph函数。
有一个名为“pylab.savefig”的功能,但似乎只有当它与绘图模块一起放置时才起作用。有没有办法完成它?
建议我对我的功能代码进行任何更改,以便我可以将图形保存到单个pdf文件中。