steadilee
FRACTAL
steadilee
전체 방문자
오늘
어제
  • 분류 전체보기 (47)
    • Knowledge (0)
      • 컴퓨터 (0)
    • Data Analysis (7)
      • 공부 (4)
      • Simple Analysis (0)
      • ML,DL (3)
      • Kaggle (0)
    • Skill (40)
      • SQL 이론 (3)
      • Oracle (18)
      • MySQL (0)
      • Python (5)
      • Linux (2)
      • C,C#,C++ (8)
      • Java (1)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
steadilee

FRACTAL

matplotlib 한글 폰트 설정하기
Skill/Python

matplotlib 한글 폰트 설정하기

2022. 6. 23. 09:36
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
    'Skill/Python' 카테고리의 다른 글
    • 오류 : 'pyinstaller'은(는) 내부 또는 외부 명령, 실행할 수 있는 프로그램, 또는 배치 파일이 아닙니다.
    • SettingWithCopyWarning 경고
    • EOL while scanning string literal
    • Python 기초 및 초급
    steadilee
    steadilee

    티스토리툴바