data analysis & visualization

 

 

 

 

 

 

In [22]:
from IPython.core.display import display, HTML

display(HTML("<style> .container{width:90% !important;}</style>"))
 
 
In [21]:
# !sudo apt install fonts-nanum
# !sudo fc-cache -fv
 
?⑦궎吏€ 紐⑸줉???쎈뒗 以묒엯?덈떎... ?꾨즺0%
?섏〈???몃━瑜?留뚮뱶??以묒엯?덈떎       
?곹깭 ?뺣낫瑜??쎈뒗 以묒엯?덈떎... ?꾨즺
fonts-nanum is already the newest version (20170925-1).
?ㅼ쓬 ?⑦궎吏€媛€ ?먮룞?쇰줈 ?ㅼ튂?섏뿀吏€留????댁긽 ?꾩슂?섏? ?딆뒿?덈떎:
  libllvm7
Use 'sudo apt autoremove' to remove it.
0媛??낃렇?덉씠?? 0媛??덈줈 ?ㅼ튂, 0媛??쒓굅 諛?28媛??낃렇?덉씠??????
In [12]:
# 일부러 오류내서 경로 확인
matplotlib.font_manager.findfont('a')

 

Out[12]:
'/root/anaconda3/envs/jupyter/lib/python3.6/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSans.ttf'
In [13]:
# !sudo cp /usr/share/fonts/truetype/nanum/Nanum* /root/anaconda3/envs/jupyter/lib/python3.6/site-packages/matplotlib/mpl-data/fonts/ttf
In [20]:
import matplotlib
import matplotlib.font_manager

[f.name for f in matplotlib.font_manager.fontManager.ttflist if 'Nanum' in f.name]
Out[20]:
['NanumGothic',
 'NanumMyeongjo',
 'NanumGothic',
 'NanumSquare',
 'NanumSquareRound',
 'NanumSquareRound',
 'NanumMyeongjo',
 'NanumSquare',
 'NanumBarunGothic',
 'NanumBarunGothic']
In [15]:
import platform
from matplotlib import font_manager, rc
import matplotlib.pyplot as plt

# 한글 사용시 마이너스 폰트가 깨지는 문제가 발생할 수 있으므로 설정변경
plt.rcParams['axes.unicode_minus'] = False

if platform.system() == 'Windows':
    path = "c:/Windows/Fonts/malgun.ttf"
    font_name = font_manager.FontProperties(fname=path).get_name()
    rc('font', family=font_name)
elif platform.system() == 'Darwin':
    rc('font', family='AppleGothic')
elif platform.system() == 'Linux':
    rc('font', family='NanumBarunGothic')
else:
    print('Unknown system... sorry~~~~~~')
In [19]:
import os
import numpy as np
np.random.seed(0)
x=range(5)
y=10+5*np.random.randn(5)
fig=plt.figure()
ax=fig.add_subplot(111)

ax.set_title('한국어를 지정한 타이틀')
ax.bar(x,y)

plt.show()
 
In [ ]: