Python/Default
Kaggle에서 한글 폰트 사용하기
퐁스
2019. 7. 12. 14:42
이런 저런 방법이 있겠지만 나는 가장 간단한 방법으로 했다. 데이터 셋에 폰트를 넣어준다.
# This Python 3 environment comes with many helpful analytics libraries installed
# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python
# For example, here's several helpful packages to load in
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import matplotlib.pyplot as plt
%matplotlib inline
from matplotlib import font_manager, rc
import seaborn as sns
# Input data files are available in the "../input/" directory.
# For example, running this (by clicking run or pressing Shift+Enter) will list the files in the input directory
import os
print(os.listdir("../input"))
# Any results you write to the current directory are saved as output.
['NanumSquare.ttf']
그럼 이렇게 들어가는데 폰트 설정만 따로 해주면된다. 참고로 폰트 잘못쓰면 철컹철컹하므로 조심해서 사용하자.
plt.rcParams['axes.unicode_minus'] = False
fontpath = "../input/NanumSquare.ttf"
fontprop = font_manager.FontProperties(fname=fontpath,size=12)
이후 설정에다가 넣어준다.
plt.plot([1,2,3], [110,130,120])
plt.title('된당',fontproperties=fontprop)
plt.show()
아이 편해.