Untitled

 avatar
unknown
plain_text
4 years ago
994 B
5
Indexable
# 2. 以此matrix產出的cluster dendrogram (50%)
# https://stackoverflow.com/questions/41462711/python-calculate-hierarchical-clustering-of-word2vec-vectors-and-plot-the-resu
from matplotlib import pyplot as plt
from matplotlib.font_manager import FontProperties
%matplotlib inline
import matplotlib.font_manager as font_manager
from scipy.cluster.hierarchy import dendrogram, linkage

# 修字體: cr to https://sujingjhong.com/posts/how-to-show-matplotlib-visual-packages-in-chinese-on-colab/
!wget 'https://noto-website-2.storage.googleapis.com/pkgs/NotoSansCJKtc-hinted.zip'
!mkdir /tmp/fonts
!unzip -o NotoSansCJKtc-hinted.zip -d /tmp/fonts/
!mv /tmp/fonts/NotoSansMonoCJKtc-Regular.otf /usr/share/fonts/truetype/NotoSansMonoCJKtc-Regular.otf -f

font_dirs = ['/usr/share/fonts/truetype/']
font_files = font_manager.findSystemFonts(fontpaths=font_dirs)

for font_file in font_files:
  font_manager.fontManager.addfont(font_file)

plt.rcParams['font.family'] = "Noto Sans Mono CJK TC"

Editor is loading...