본문 바로가기

Computer Science/Jupyter notebook

데이터 시각화(matplotlib, seaborn 입문)

 

파이썬으로 차트들을 쉽게 그릴 수 있도록 하는 가장 유명한 데이터 시각화 라이브러리

 matplotlib 기본 문법

 

1. 기본적인 그래프

 

첫번째 줄은 주피터 노트북 안에 차트가 그려지도록 하는 문장입니다. 가장 간단하게 직접 좌표 찍어서 그리는 방식!

 

2. 데이터, 축 이름, 범례 추가

 

여기에 다양한 세부 내용들을 추가할 수 있습니다. 

 

3. 막대 차트 그리기

 

꺾은 선 그래프 외에 bar chart도 그릴 수 있습니다.

 

4. 다양한 차트 스타일

 

그 외에도 차트는 스타일을 다양하게 변경할 수 있습니다.

 

* marker : https://matplotlib.org/3.1.1/api/markers_api.html

* color name : https://matplotlib.org/3.1.1/gallery/color/named_colors.html#sphx-glr-gallery-color-named-colors-py

* 더 다양한 양식들은 아래 홈페이지에서 확인 가능합니다.

https://matplotlib.org/3.1.1/gallery/index.html#color-examples

 

Gallery — Matplotlib 3.1.2 documentation

Gallery This gallery contains examples of the many things you can do with Matplotlib. Click on any image to see the full image and source code. For longer tutorials, see our tutorials page. You can also find external resources and a FAQ in our user guide.

matplotlib.org

 


 

matplotlib을 기반으로 만들어진 통계     데이터 시각화 최적화 라이브러리

 

1. 판다스로 불러온 후, seaborn 불러오기

 

2. 데이터 불러오고, 차트 작성

 

범주와 사이즈 조절 넣기도 가능합니다. Categorical Scatter Plot 작성예시입니다.

 

3. 박스 그림상자(Box plot)

 

 

 
Box Plot 이해하기

   * 더 많은 차트는 아래 사이트에서 확인 가능합니다.

https://seaborn.pydata.org/index.html

 

seaborn: statistical data visualization — seaborn 0.10.1 documentation

Seaborn is a Python data visualization library based on matplotlib. It provides a high-level interface for drawing attractive and informative statistical graphics. For a brief introduction to the ideas behind the library, you can read the introductory note

seaborn.pydata.org