혼자 공부하는 데이터 분석 with 파이썬 - 예스24
혼자 해도 충분하다! 1:1 과외하듯 배우는 데이터 분석 자습서이 책은 독학으로 데이터 분석을 배우는 입문자가 ‘꼭 필요한 내용을 제대로 학습’할 수 있도록 구성했습니다. 뭘 모르는지조차
www.yes24.com
https://www.yes24.com/Product/Goods/116253011
5주차(25.2.10 - 2.16) Chapter 05 데이터 시각화하기
기본미션
▶ p.314 손코딩 그래프 출력(bar 함수로 막대 그래프 그리기)
# 막대 그래프 그리기
plt.bar(count_by_subject.index, count_by_subject.values)
plt.title('Books by subject')
plt.xlabel('subject')
plt.ylabel('number of books')
for idx, val in count_by_subject.items():
plt.annotate(val, (idx, val), xytext=(0, 2), textcoords='offset points')
plt.show()
추가미션
▶ p.316 손코딩 출력(텍스트 정렬, 막대 조절 및 색상 바꾸기)
plt.bar(count_by_subject.index, count_by_subject.values, width=0.7, color='blue')
plt.title('Books by subject')
plt.xlabel('subject')
plt.ylabel('number of books')
for idx, val in count_by_subject.items():
plt.annotate(val, (idx, val), xytext=(0, 2), textcoords='offset points',
fontsize=8, ha='center', color='green')
plt.show()
+ 그래프 그리드 추가
# 막대 그래프 설정
plt.bar(count_by_subject.index, count_by_subject.values, color='#e35f62', edgecolor='black', linewidth=0.5)
# 제목과 축 레이블
plt.title('Books by Subject', fontsize=16, color='#e35f62')
plt.xlabel('Subject', fontsize=14, color='#e35f62')
plt.ylabel('Number of Books', fontsize=14, color='#e35f62')
# x축 눈금 설정
plt.xticks(fontsize=10, color='black')
# y축 눈금 설정
plt.yticks(fontsize=12)
# 그리드 추가
plt.grid(True, axis='y', linestyle='--', color='gray', alpha=0.5)
# 막대 위에 값 표시
for idx, val in count_by_subject.items():
plt.annotate(val, (idx, val), xytext=(0, 5), textcoords='offset points',
ha='center', fontsize=8, color='#e35f62')
# 그래프 출력
plt.tight_layout() # 레이아웃 자동 조정
plt.show()
'혼공학습단(한빛미디어)' 카테고리의 다른 글
[혼공단] 혼공학습단 13기 활동 회고(25. 1. 6 ~ 25. 2. 23) (1) | 2025.02.23 |
---|---|
[혼공단13기] 혼자 공부하는 데이터 분석 with 파이썬 - 6주차 (2) | 2025.02.18 |
[혼공단13기] 혼자 공부하는 데이터 분석 with 파이썬 - 4주차 (0) | 2025.02.08 |
[혼공단13기] 혼자 공부하는 데이터 분석 with 파이썬 - 3주차 (0) | 2025.01.24 |
[혼공단13기] 혼자 공부하는 데이터 분석 with 파이썬 - 2주차 (0) | 2025.01.17 |