def plot_scattermatrix_reduced(df, title = "plot_scattermatrix_reduced"):
input_cols = [i for i in df.columns if i.startswith("X")]
output_cols = [i for i in df.columns if i.startswith("Y")]
Xs = df[input_cols]
Ys = df[output_cols]
numsamples = df.shape[0]
print "plot_scattermatrix_reduced: numsamples = %d" % numsamples
# numplots = Xs.shape[1] * Ys.shape[1]
# print "numplots = %d" % numplots
gs = gridspec.GridSpec(Ys.shape[1], Xs.shape[1])
pl.ioff()
fig = pl.figure()
fig.suptitle(title)
# alpha = 1.0 / np.power(numsamples, 1.0/(Xs.shape[1] - 0))
alpha = 0.2
print "alpha", alpha
cols = ["k", "b", "r", "g", "c", "m", "y"]
for i in range(Xs.shape[1]):
for j in range(Ys.shape[1]):
# print "i, j", i, j, Xs, Ys
ax = fig.add_subplot(gs[j, i])
ax.plot(Xs.as_matrix()[:,i], Ys.as_matrix()[:,j], "ko", alpha = alpha)
ax.set_xlabel(input_cols[i])
ax.set_ylabel(output_cols[j])
if SAVEPLOTS:
fig.savefig("fig_%03d_scattermatrix_reduced.pdf" % (fig.number), dpi=300)
fig.show()
评论列表
文章目录