How to put a title on each scattered matrix in jupyter + pandas

So, I have several data set samples taken at different times. For each sample, I want to build a scattering matrix, and each scattering matrix should have a sampling time as a name.

The problem is the lack of an argument "title" for pandas.tools.plotting.scatter_matrix

When I try to print () the title before the graphic, it will print all the titles before the graphic.

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)

By running the code, all the headers will be printed before the first scattering matrix is ​​finally drawn:

The result was not as expected

Any ideas?

+4
source share
2 answers

print(date). plt.suptitle(date) scatter_matrix, .

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)
+2

, , - matplotlib, pandas. : http://pandas.pydata.org/pandas-docs/stable/visualization.html#plotting-directly-with-matplotlib

, -

dummy = scatter_matrix(df, alpha=0.3, figsize=(16,16), diagonal='kde', marker=date)
plt.figure()
plt.title(date)
plt.plot(dummy)
plt.show()
0

All Articles