티스토리 뷰
step1. 맥북 한글 폰트 설정: AppleGothic이용하기
from matplotlib import font_manager, rc
rc('font', family = 'AppleGothic')
step2. csv파일 안깨지게 불러오기
- 먼저 엑셀 csv 파일을 저장할 때 UTF-8 CSV파일로 저장함
- 한글이 깨지면 engine = 'python'이용
df = pd.read_csv('경로/파일이름.csv', engine = 'python)
⇨ 데이터 프레임 출력 결과
선수명 | 경기수 | 타수 | 득점 | 안타 |
홍길동 | 137 | 476 | 84 | 176 |
일지매 | 131 | 483 | 91 | 177 |
전우치 | 106 | 388 | 84 | 141 |
강감찬 | 125 | 498 | 103 | 173 |
step3. 컬럼별로 데이터 만들기
data1 = df['경기수']
data2 = df['득점']
data3 = df['안타']
name = df['선수명']
step4. 라인그래프 설정
plt.style.use('ggplot')
fig = plt.figure()
ax = fig.add_subplot(111)
step5. 그래프 그리기
plt.style.use('ggplot')
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(name, data1, label = '경기수')
ax.plot(name, data2, label = '득점')
ax.plot(name, data3, label = '안타')
step6. 축 제목과 범례 그리기
plt.style.use('ggplot')
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(name , data1 , label = '경기수')
ax.plot(name , data2 , label = '득점')
ax.plot(name , data3 , label = '안타')
ax.set_title('선수별 기록')
ax.set_ylabel('건수(단위:건)')
ax.set_xlabel('선수명')
ax.legend(loc=1)
plt.show()
'파이썬' 카테고리의 다른 글
결측치 처리 (0) | 2023.03.26 |
---|---|
파이썬 활용하여 자동으로 이메일 보내기 (0) | 2021.06.13 |
여러가지 통계분석 (0) | 2021.06.13 |
nltk 패키지 / 영문 텍스트 분석하기 / 워드클라우드 (0) | 2021.06.13 |
(MAC OS)matplotlib을 이용한 다양한 그래프 그리기 / bokeh 그래프 그리기 (0) | 2021.06.13 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 코드
- mysql
- R
- python
- 그래프
- 프로그래머스
- sql
- 코딩
- plot
- 금리
- 보안
- 파이썬
- SW
- 자바
- 코딩테스트
- 영어회화
- 경제
- 클래스
- 함수
- 영어
- 개발
- 모듈
- 프로그래밍
- 데이터
- 머신러닝
- 코테
- 경제신문
- 데이터분석
- 스마트워치
- Programming
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함