Crawling/데이터 시각화

데이터시각화_10가지_Heat map

km1n 2022. 1. 6. 17:12

파이썬 시각화 차트 종류

1. Column/Bar chart
2. Dual Axis, 파레토 chart
3. Pie chart
4. Line chart
5. Scatter chart
6. Bubble chart
7. Heat map
8. Histogram
9. Box plot
10. Geo chart

 

 

변수 간의 상관관계를 보여준다.

marathon_2015_2017 = pd.read_csv('./data_boston/marathon_2015_2017.csv')

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
sns.set()
marathon_2015_2017_under60 = marathon_2015_2017[marathon_2015_2017.Age.isin(range(0, 60))]
marathon_2015_2017_under60.info()
marathon_2015_2017_under60.groupby('Age')['M/F'].value_counts()
marathon = marathon_2015_2017_under60.groupby('Age')['M/F'].value_counts().unstack().fillna(0)
marathon
marathon_2015_2017_under60.groupby('Age')['M/F'].value_counts()
marathon

subplots()에선 두개의 값을 받을 수 있는데 figure 와 axes 값을 받을 수 있다.
여기서 변수명은 상관없다. 순서가 중요하다

fig란 figure로써 - 전체 subplot을 말한다. ex) 서브플로안에 몇개의 그래프가 있던지 상관없이  그걸 담는 하나. 전체 사이즈를 말한다.

ax는 axe로써 - 전체 중 낱낱개를 말한다 ex) 서브플롯 안에 2개(a1,a2)의 그래프가 있다면 a1, a2 를 일컬음

 

f, ax = plt.subplots(figsize=(10,20))

sns.heatmap(marathon, annot=True, fmt='d', linewidths=.5, ax=ax)  # cmap='Accent'
plt.show()