[英]Python 3.4 MatPlotLib PdfPages Value Error
I keep trying to follow the examples I see for PdfPages but keep getting the value error: No such figure: None. 我一直尝试遵循我在PdfPages上看到的示例,但始终收到值错误:无此数字:无。
plot1 = Chart Generating Function(argument1, argument2,...)
from matplotlib.backends.backend_pdf import PdfPages
pp = PdfPages('sample.pdf')
pp.savefig(plot1)
plt.close()
I've tried different variations of this (ie pdf.savefig()) but nothing seems to work. 我已经尝试过这种变化(即pdf.savefig()),但似乎没有任何效果。
I should have added more details, but somewhere in my code I had used "fig, ax = ..." when defining the figure. 我应该添加更多详细信息,但是在定义代码时,在代码的某个地方使用了“ fig,ax = ...”。 The "fig" part needed to be the argument in pdf.savefig(fig) in order for it to work.
“ fig”部分必须是pdf.savefig(fig)中的参数,以便它起作用。
对我来说解决问题的是在图表生成函数末尾删除了plt.show()
命令。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.