Python 문법/Pandas_Matplotlib & Seaborn

[상관관계차트] plot(), .sort_values().plot() 그래프로 컬럼의 데이터 비교

jasonshin 2021. 11. 22. 12:44

데이터프레임의 plot 함수는 x축에는 인덱스를 y축에는 컬럼의 값을 세팅한다. 

plt.plot(df)

plt.show()

 

df.plot()

plt.show()

bar로 표현

df['가져올 컬럼'].plot(kind='bar')
plt.show()

 

 

수평으로 변경

df['가져올컬럼'].plot(kind='barh')
plt.show()

 

 

 

사이즈변경

plt.figure(figsize =(10, 8))
df['가져올컬럼'].plot(kind='barh')
plt.show()

 

 

정렬해서 그리기

df['가져올컬럼'].sort_values().plot(kind='bar')
plt.show()

 

 

오름차순으로 정렬해서 그리기

df['가져올컬럼'].sort_values(ascending=False).plot(kind='bar')
plt.show()

 

반응형