Skip to content

Instantly share code, notes, and snippets.

@howard-haowen
Last active December 21, 2020 15:15
Show Gist options
  • Select an option

  • Save howard-haowen/01054f92410208c49463970b7823214c to your computer and use it in GitHub Desktop.

Select an option

Save howard-haowen/01054f92410208c49463970b7823214c to your computer and use it in GitHub Desktop.
Fix font display for Matplotlib
# Method 1
# 須先下載wqy-microhei.ttc,因中文顯示需做特殊處理
zhfont = matplotlib.font_manager.FontProperties(fname='/Users/youngmihuang/Downloads/wqy-microhei.ttc')
==================================
# Method 2
# install Korean font
!apt install fonts-nanum
import matplotlib.pyplot as plt
import matplotlib.font_manager as fm
# set the font and rebuild font manager
plt.rc('font', family='NanumBarunGothic')
fm._rebuild()
# set high resolution to show the font clearly
%config InlineBackend.figure_format = 'retina'
# After executing this cell,
# you need to click "Restart runtime..."(Cmd/Ctrl+M .)
# and then execute this cell again.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment