티스토리 뷰
데이터 시각화
[seaborn 그래프 튜토리얼] 04. 기본/통계형 그래프 (countplot, distplot, heatmap, catplot)
지휘리릭 2023. 12. 29. 14:03countplot
- 카테고리별 데이터 값을 셀 수 있음
- 별도의 집계 코드를 작성하지 않아도 됨
- matplotlib 에서 카운팅 그래프를 그리기 위해선, 카테고리별 집계 코드가 필요함
import seaborn as sns
titanic = sns.load_dataset('titanic')
sns.countplot(x="class", data=titanic)
plt.show()
distplot
- 히스토그램 그릴 때 사용
- 러그나 커널 밀도와 같이 추정된 확률밀도함수 표시 기능이 있음
- hist_kws : 그래프를 꾸밀 수 있음
- edgecolor : 바그래프 테두리 색상
- facecolor : 바그래프 내부 색상
- linewidth : 바그래프 테두리 굵기
x = np.random.randn(200)
sns.distplot(x, kde=True, hist_kws={"facecolor":"red", "edgecolor":"black", "linewidth":2})
heatmap
- 데이터의 상관관계나 pivot 테이블을 시각화하고 싶을 때 사용
- 데이터 상관관계 구하는 함수 사용 corr()
- 옵션
- annot : 셀 안에 값 표시 여부
plt.figure(figsize=(10,6))
sns.heatmap(titanic.corr(), annot=True, cmap='RdYlGn')
catplot
- categorical plot
- 카테고리형 변수를 시각화할 때 사용
- 옵션
- col : 지정한 컬럼의 값에 따라 다중 그래프 생성
- kind : 차트 종류
- bar : 자동으로 값의 범위가 계산되어 그래프가 그려짐
- strip : 기본값
- swarm
- box
- violin
- boxen
- point
- bar
- count
sns.set(style='darkgrid')
sns.catplot(x="who", y="survived", data=titanic).set(title="kind = strip")
sns.catplot(x="who", y="survived", data=titanic, kind="bar").set(title="kind = bar")
sns.catplot(x="who", y="survived", col="class", data=titanic, kind="violin")
'데이터 시각화' 카테고리의 다른 글
[데이터 시각화 연습] 서울 미용실 현황 알아보기 (2) | 2024.01.02 |
---|---|
[seaborn 그래프 튜토리얼] 03. 기본/통계형 그래프 (lmplot) (0) | 2023.12.28 |
[seaborn 그래프 튜토리얼] 02. 기본/통계형 그래프 (relplot) (0) | 2023.12.28 |
[seaborn 그래프 튜토리얼] 01. seaborn (특징, 옵션) (0) | 2023.12.28 |
[matplotlib 그래프 튜토리얼] 07. 그래프 (hist, scatter, imshow) (0) | 2023.12.28 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- Firebase 데이터베이스 추천
- 데이터베이스 추천
- 장고 태그달기
- django pythoneverywhere
- 장고 게시판
- django 태그
- 실시간 데이터베이스
- iOS 화면 안나옴
- django 로그인접근
- pythonanywhere배포
- UITableViewController Not Working
- CellForRowAt 호출안됨
- 웹 배포
- django 게시판
- CellForRowAt Not Called
- python 웹 배포
- 까만 화면
- iOS 데이터베이스
- ModelForm Form 차이
- 테이블출력안됨
- Django
- iOS 검은 화면
- django clean
- django 개발일지
- iOS UITableView 출력안됨
- cleaned_data
- django tag
- pythonanywhere배포방법
- Realtime Database
- 알파벳 카운팅
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
글 보관함