0
PDFファイルに余分なページがあるのはなぜですか?ロードされるファイルは7つしかありませんが、PDF出力ファイルには8つが作成されています。以下は、私が作業しているコードです。ロードされているファイルは実際には問題を避けるためにそれぞれ異なる名前に名前を変更した1つのファイルのコピーです。実際の内容が同じであるということは間違いないと思いますか?matplotlibからPDF出力で余分なページを作成する方法を教えてください。PdfPages function
編集:..私はそれがロードされ、二回作成されたPDFファイルに追加の最後のファイルだことを確認することができましたが、なぜ私はまだ見ていない
def processFiles():
##Set some vars
global kdeData
counter = 0
sColumn = selectCol()
sSamples = setSamples()
rfName = raw_input("Name of file to save results to: ")+".pdf"
createPDF = PdfPages(rfName)
##Iterate for each file
for file in fileList:
valid = [sColumn]
matrix = np.loadtxt(file, skiprows=1, usecols=valid)
colCount = np.loadtxt(file, dtype=object)
totalCols = colCount.shape[1]
ldlValid = [i for i in range(totalCols)]
lDL = np.loadtxt(file, usecols=ldlValid, dtype=object)
kdeData = np.array(matrix)
gkde = stats.gaussian_kde(kdeData)
ind = np.linspace(-int(getRange()), int(getRange()), len(kdeData) * sSamples)
kdepdf = gkde.evaluate(ind)
plt.figure()
##plot histogram of sample
plt.hist(kdeData, len(kdeData), normed=1, alpha=0.20)
##plot data generating density
plt.plot(ind, stats.norm.pdf(ind), 'r', linewidth=0.8, label='DGP normal')
##plot estimated density
plt.plot(ind, kdepdf, 'g', linewidth=0.8, label='kde')
plt.title('KDE for '+str(nameList[counter]))
plt.legend()
plt.savefig(createPDF, format='pdf')
counter += 1
##Save PDF and open it
createPDF.savefig()
createPDF.close()
os.startfile(rfName)
ああ...私はドキュメントの読み方を間違えたと思って、両方が必要だと思った。彼らは同じことをするための2つの代替方法を提供しているようです。ありがとう。 – DamianJ