[Visualization] - 유용한 TIP 정리
2020. 12. 30. 21:30ㆍ[TIPs]/Visualization
[warning 안 뜨게 하는 방법]
import warnings
warnings.filterwarnings("ignore")
[데이터 시각화 할 때 한글 폰트 안 나온다면..?]
!sudo apt-get install -y fonts-nanum
!sudo fc-cache -fv
!rm ~/.cache/matplotlib -rf
입력 후 엔터!
그리고 '런타임 다시 시작' 후
import matplotlib.pyplot as plt
plt.rc('font', family='NanumGothic') # 기타 nanum font 써도 됨
하면 정상적으로 나오더라~
[Matplotlib]
[Types]
#matplotlib 정리 (수동)
# errorbar
plt.errorbar(x=,y=,yerr=,linestyle=)
# barplot
plt.bar(x=, height= , data = )
# scatterplot
plt.scatter(x=,y=)
# piechart
plt.pie(x=[val1,val2,val3],labels=['val1','val2','val3'],autopct='%.2f%%')
# histogram
plt.hist(x=)
[etc]
# grid
plt.grid(True)
# x,y coordinate limitation
plt.xlim([a,b]) # a~b 사이
plt.ylim([c,d]) # c~d 사이
[Seaborn]
[Types]
# seaborn 정리 (자동)
#pointplot
sns.pointplot(x,y,data,yerr,linestyles)
#barplot
sns.barplot(x=,y=,hue=,data=)
#countplot
sns.countplot(x=,hue=,data=)
#Facet
g = sns.FacetGrid(data=,col=)
# 작성 예시
g = g.map(
sns.countplot,
"pclass",
order= sorted(titanic['pclass'].value_counts().index)
)
[etc]
# 그래프에 text 쓰기
g.text(x=1,y=450, s = 450, horizontalalignment='center',weight='bold')
# x,y 좌표에 450이라는 숫자값을 표시하겠다는 의미
728x90