因此,我在不同时间对数据集进行了多次采样.
对于每个采样,我想绘制一个散射矩阵,每个散射矩阵应该将采样时间作为标题.
问题是pandas.tools.plotting.scatter_matrix没有参数“title”
当我在绘制图形之前尝试打印()标题时,它会在绘制图形之前打印所有标题.
for qid in qids:
date = db[collection].find_one({ "querySummary.qid": qid }, {"querySummary.date":1})["querySummary"]["date"].isoformat()
print(date) # does not provide the desired result
cursor = db[collection].find({ "querySummary.qid": qid })
cols = ["resultNum", "col2", "col3", "col4"] # list of columns labels
rows = [] # will be populated below
for result in cursor:
rows.append([result["resultNum"], result["col2"], result["col3"], result["col4"]])
df = pd.DataFrame(rows, columns=cols);
scatter_matrix(df, alpha=0.3, figsize=(16,16), diagonal='kde', marker=date)
通过运行代码,在最终绘制第一个scatter_matrix之前,所有标题都会打印出来:
有任何想法吗?
解决方法:
在这种情况下,您不能使用print(日期).相反,请为每个scatter_matrix尝试plt.suptitle(date),如下所示.
for qid in qids:
date = db[collection].find_one({ "querySummary.qid": qid }, {"querySummary.date":1})["querySummary"]["date"].isoformat()
cursor = db[collection].find({ "querySummary.qid": qid })
cols = ["resultNum", "col2", "col3", "col4"] # list of columns labels
rows = [] # will be populated below
for result in cursor:
rows.append([result["resultNum"], result["col2"], result["col3"], result["col4"]])
df = pd.DataFrame(rows, columns=cols);
scatter_matrix(df, alpha=0.3, figsize=(16,16), diagonal='kde', marker='o')
plt.suptitle(date)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。