我使用pandas plotting toolkit绘制一些数据的散点图。
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from pandas.tools.plotting import scatter_matrix
data = pd.read_csv('results_true.csv',header=False)
data = data.drop('Unnamed: 0',axis=1)
ax = scatter_matrix(data,diagonal='hist',alpha=0.5,
hist_kwds={'bins':np.sqrt(999),'alpha':0.9,'histtype':'step'},
grid=True,range_padding=0.4,
figsize=(15,15),marker='o',s=0.3)
plt.clf()
new_ax = np.empty(ax.shape,dtype=object)
for i in xrange(0,ax.shape[0]):
for j in xrange(0,ax.shape[1]):
if j >= i:
new_ax[i][j] = ax[i][j]
new_ax终端的输出是
array([[<matplotlib.axes.AxesSubplot object at 0x9c4f74c>,
<matplotlib.axes.AxesSubplot object at 0x9f256cc>,
<matplotlib.axes.AxesSubplot object at 0x9fa9b8c>,
<matplotlib.axes.AxesSubplot object at 0xa04758c>,
...,
[None, None, None, None, None, None, None, None, None, None, None,
<matplotlib.axes.AxesSubplot object at 0xed9c30c>]],
dtype=object)
我这样做,所以我只能绘制一半的散射矩阵而不是冗余的顶部对角线。有没有办法可以在形式上绘制new_ax?