Last active
September 26, 2022 08:13
-
-
Save korakot/3021b0027607b8102d98faee3a7e156a to your computer and use it in GitHub Desktop.
Set matplotlib to Thai font on MacOS
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
| # download font file มาก่อน | |
| !wget https://awards.opdc.go.th/awards_opdc/assets/fonts/THSarabunNew/THSarabunNew.ttf | |
| # import and install | |
| import matplotlib.pyplot as plt | |
| import matplotlib.font_manager as fm | |
| font_list = fm.createFontList(['THSarabunNew.ttf']) | |
| fm.fontManager.ttflist.extend(font_list) | |
| # set font | |
| plt.rcParams['font.family'] = 'TH Sarabun New' | |
| plt.rcParams['xtick.labelsize'] = 20.0 | |
| plt.rcParams['ytick.labelsize'] = 20.0 | |
| # plot | |
| plt.bar(['ก','ข','ค'], [1,2,3]); |
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
| import matplotlib | |
| matplotlib.rc('font', family='Ayuthaya') # MacOS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment