LoginSignup
1
0

More than 5 years have passed since last update.

散布図行列

「スポーツテストデータ」を例に説明します。

# データフレーム操作に関するライブラリをインポートする
import pandas as pd
from pandas.tools import plotting # 高度なプロットを行うツールのインポート
# 「#」(シャープ)以降の文字はプログラムに影響しません。
# 図やグラフを図示するためのライブラリをインポートする。
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
%matplotlib inline
# URL によるリソースへのアクセスを提供するライブラリをインポートする。
# import urllib # Python 2 の場合
import urllib.request # Python 3 の場合
# ウェブ上のリソースを指定する
url = 'https://raw.githubusercontent.com/maskot1977/ipython_notebook/master/toydata/sports_dataJt.txt'
# 指定したURLからリソースをダウンロードし、名前をつける。
# urllib.urlretrieve(url, 'sports_dataJt.txt') # Python 2 の場合
urllib.request.urlretrieve(url, 'sports_dataJt.txt') # Python 3 の場合
# データの読み込み
df = pd.read_csv('sports_dataJt.txt', sep='\t', index_col=0) 
df
df.columns[4:14]
# 散布図行列(左側の4列だけ)
plotting.scatter_matrix(df.dropna(axis=1)[df.columns[0:4]], figsize=(8, 8)) 
plt.show()
# 散布図行列
plotting.scatter_matrix(df.dropna(axis=1)[df.columns[:]], figsize=(20, 20)) 
plt.show()
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0