1. 程式人生 > >1.2為多變數資料繪製散點陣圖

1.2為多變數資料繪製散點陣圖

1 # 繪出6個圖形,包括了以下幾個列:花萼長度、花萼寬度、花瓣長度和花瓣寬度 2 plt.close('all') # 關掉其他的影象 3 plt.figure(1) 4 5 # 繪製一個3行2列的圖 6 subplot_start = 321 7 col_numbers = range(0, 4) 8 # 為圖形新增標籤 9 col_pairs = itertools.combinations(col_numbers, 2) 10 plt.subplots_adjust(wspace = 0.5) 11 12 for col_pair in col_pairs:
13 plt.subplot(subplot_start) 14 plt.scatter(x[:,col_pair[0]], x[:,col_pair[1]], c=y) 15 plt.xlabel(col_names[col_pair[0]]) 16 plt.ylabel(col_names[col_pair[1]]) 17 subplot_start += 1 18 plt.show()