本文整理汇总了Python中matplotlib.backends.backend_pdf.PdfPages.attach_note方法的典型用法代码示例。如果您正苦于以下问题:Python PdfPages.attach_note方法的具体用法?Python PdfPages.attach_note怎么用?Python PdfPages.attach_note使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_pdf.PdfPages
的用法示例。
在下文中一共展示了PdfPages.attach_note方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: savePlotsToPDF
# 需要导入模块: from matplotlib.backends.backend_pdf import PdfPages [as 别名]
# 或者: from matplotlib.backends.backend_pdf.PdfPages import attach_note [as 别名]
def savePlotsToPDF(uRMSE, uProbs, uStats, pdfFName):
#get max RMSE
maxRMSE = 0
for user, rmses in uRMSE.iteritems():
if max(rmses) > maxRMSE:
maxRMSE = max(rmses)
#get max probs
minProb = 0
maxProb = -100
for user, probs in uProbs.iteritems():
if min(probs) < minProb:
minProb = min(probs)
if max(probs) > maxProb:
maxProb = max(probs)
pp = PdfPages(pdfFName)
users = uRMSE.keys()
users.sort()
nRatingsUser = []
for user in users:
nRatingsUser.append((uStats[user][0], user))
nRatingsUser.sort()
for (nRat, user) in nRatingsUser:
rmses = uRMSE[user]
plt.figure()
plt.clf()
plt.subplot(1, 2, 1)
plt.plot(range(len(rmses)), rmses)
axes = plt.gca()
axes.set_ylim([0, maxRMSE])
plt.xlabel('buckets')
plt.xticks(range(len(rmses)))
plt.ylabel('RMSE')
plt.grid()
#plt.title('user: ' + str(user))
plt.suptitle('user: ' + str(user) + ' ratings: '
+ str(uStats[user][0]) + ' 2Hop users: '
+ str(uStats[user][1]) + ' meanIFreq: '
+ str(uStats[user][2]) + ' topItems: '
+ str(uStats[user][3]))
probs = uProbs[user]
#print probs[0]
plt.subplot(1, 2, 2)
plt.plot(range(len(probs)), probs)
axes = plt.gca()
axes.set_ylim([minProb, maxProb])
plt.xlabel('buckets')
plt.xticks(range(len(probs)))
plt.ylabel('average steady state probabilities (log10)')
plt.tight_layout()
plt.subplots_adjust(top = 0.90)
pp.attach_note('user: ' + str(user) + ' ratings: '
+ str(uStats[user][0]) + ' twoHop users: '
+ str(uStats[user][1]) + ' mean itemFreq: '
+ str(uStats[user][2]) + ' top500Items: '
+ str(uStats[user][3]))
pp.savefig()
plt.close()
pp.close()