Last active
December 21, 2020 15:15
-
-
Save howard-haowen/01054f92410208c49463970b7823214c to your computer and use it in GitHub Desktop.
Fix font display for Matplotlib
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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