LoginSignup
0
2

More than 1 year has passed since last update.

Pythonによるグラフ化コードまとめ

Posted at

グラフ関係

コード忘れたとき用にメモしてます。

#横軸の値
x = df['Origin'].value_counts().index
#縦軸の値
height = df['Origin'].value_counts().values

#図のサイズを規定
plt.figure(figsize=(12,8))

#グラフのスタイル変更
plt.style.use('seaborn')

#棒グラフ
plt.bar(x=columns, height=model.coef_);

#折れ線グラフ
plt.plot(x, y)

#ヒストグラム
plt.hist(df['Acceleration'], bins=50)

#ヒストグラム2
sns.distplot(df['Acceleration'], kde=False, bins=10)

#ヒストグラムを線で表現したやつ
sns.distplot(df['Acceleration'], kde=True, bins=10)

#散布図
plt.scatter(df['Weight'], df['MPG'])

#要素同士の散布図一覧(重くなりがちだが、分析してる感が出る)
sns.pairplot(df)


#ヒストグラムと散布図
sns.jointplot(x='x1', y='x16', data=df)

#箱ひげ図
plt.boxplot(df['Acceleration'])

#ヒートマップ
sns.heatmap(df_corr.iloc[:20, :20],annot=True, cmap='Blues')

#円グラフ
x = df['満足度'].value_counts()
plt.title('満足度') # タイトルの表示  
plt.pie(x, labels=x.index, autopct='%.1f%%');

グラフのほかのコードを見つけたら追記してきます。

0
2
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
0
2