1 from matplotlib import font_manager, rc
3 font_path = "c:/Windows/Fonts/malgun.ttf"
4 font_name = font_manager.FontProperties(fname=font_path).get_name()
5 rc('font', family=font_name)
# 실행하고자 하는 코드 작성
1 matplotlib 에서 font_manager, rc 사용
3 폰트 경로 지정
4 font_manager의 FontProperties 에 폰트 경로를 주고 폰트 이름을 가져옴(font_name)
5 rc를 이용해 폰트를 4에서 얻어온 font_name으로 설정
# 실행하고자 하는 코드 수행
[예시]
from matplotlib import font_manager, rc
font = font_manager.FontProperties(fname="c:/Windows/Fonts/malgun.ttf").get_name()
rc('font', family=font)
import pandas as pd
emp15 = pd.read_csv("d:\\data\emp15_v5.txt", sep = "," , engine='python', encoding = "utf8")
result = emp15.groupby('telecom')['empno'].count().reset_index()
result.columns = ['통신사','통신사별인원수']
result.plot.pie(y='통신사별인원수',labels = ['kt','lg','sk'],autopct = '%1.1f%%', colors = ['lightskyblue','sandybrown','darkseagreen'])
한글 폰트가 깨지지 않고 잘 보이는 걸 확인할 수 있다~
'Skill > Python' 카테고리의 다른 글
오류 : 'pyinstaller'은(는) 내부 또는 외부 명령, 실행할 수 있는 프로그램, 또는 배치 파일이 아닙니다. (0) | 2022.10.05 |
---|---|
SettingWithCopyWarning 경고 (0) | 2022.07.26 |
EOL while scanning string literal (0) | 2022.05.09 |
Python 기초 및 초급 (0) | 2022.05.02 |