Python 3.4 MatPlotLib PdfPages值错误

时间:2015-11-20 03:57:29

标签: python matplotlib pdfpages

我一直在尝试按照我看到的PdfPages示例,但不断得到值错误:没有这样的数字:无。

plot1 = Chart Generating Function(argument1, argument2,...)

from matplotlib.backends.backend_pdf import PdfPages

pp = PdfPages('sample.pdf')
pp.savefig(plot1)
plt.close() 

我尝试了不同的变体(即pdf.savefig())但似乎没有任何效果。

2 个答案:

答案 0 :(得分:0)

我应该添加更多细节,但在我的代码中的某个地方,我在定义图时使用了“fig,ax = ...”。 “无花果”部分需要成为pdf.savefig(图)中的参数才能使其发挥作用。

答案 1 :(得分:0)

为我解决了这个问题的是,在图表生成功能的末尾删除了plt.show()命令。