import matplotlib
import matplotlib.pyplot as plt
%matplotlib inline
plt.rcParams['font.family'] = 'Malgun Gothic'
1/ 내가 지정한 도화지(figure), 위치(ax)에 그림 그리기
figure > 하나의 그래프
fig, ax = plt.subplots()
fig, ax = plt.subplots(figsize=(5,3))
train['Survived'].value_counts().plot.bar(fontsize=10, color='g', rot=0)
ax.set(xticklabels=['사망','생존'])
figure > 여러개의 그래프
fig, ax = plt.subplots(n,m)
fig, ax = plt.subplots(2,2, figsize=(7,5)) #도화지
labels = ['사망','생존']
train['Survived'].value_counts().plot.bar(ax=ax[0,0], color='g', rot=0)
# ax[0,0].set(xlabel='Survived', xticklabels=labels, ylabel = 'Count')
train['Survived'].value_counts().plot.pie(ax=ax[1,1], startangle=90,
autopct='%.1f%%', fontsize=13, labels=['사망','생존'])
# ax[1,1].set(title = 'Survived - pie', ylabel = '')
2/ figure, ax를 설정한 뒤 해당 자리에 그림 그리기
plt.figure(figsize=(7,4)) #도화지
plt.subplot(2,2,1)
train['Survived'].value_counts().plot.bar()
plt.subplot(2,2,4)
train['Survived'].value_counts().plot(kind='bar') # 위와 같은 그래프.
'노트1 > Python' 카테고리의 다른 글
머신러닝 회귀 모델(Regression Model)의 평가 지표 : MAE, MSE, RMSE, RMSLE (0) | 2022.01.20 |
---|---|
[Python] 서버에 HTTP 요청을 보내고(urllib/requests) Response에 접근하기(content/text) (0) | 2022.01.20 |
[Python] 네이버 OPEN API 사용법 (네이버 블로그 크롤링, iframe, Selenium) (0) | 2021.12.14 |
[Python] 공공데이터 포털 OPEN API 사용법 (xml > 데이터프레임 변환, BeautifulSoup) (0) | 2021.12.10 |
[Python] 공공데이터 포털의 OPEN API 사용법 (xml > 데이터프레임 변환, xmltodict) (0) | 2021.12.10 |