Ubuntu 管理心得

搜尋此網誌

2022年2月17日 星期四

Matplotlib 顯示中文

 cf: https://mathsyouth.github.io/2019/06/12/macos-matplotlib

  1. Run shell command:
    fc-list :lang=zh

    to find the fonts pathes, e.g. /usr/share/fonts/truetype/bkai00mp.ttf
  2. Follow the python codes below:
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rcParams
    from matplotlib.font_manager import FontProperties
    rcParams['axes.unicode_minus']=False
    myfont_kai=FontProperties(fname='/usr/share/fonts/truetype/bkai00mp.ttf', size=15)
    myfont_ming=FontProperties(fname='/usr/share/fonts/truetype/arphic-bsmi00lp/bsmi00lp.ttf',size=12)
    x=np.linspace(0,2*np.pi,100)
    plt.plot(x,x)
    plt.title("準則", fontproperties=myfont_kai)
    plt.ylabel("隸屬度", fontproperties=myfont_ming)

沒有留言:

張貼留言

網誌存檔