change matplotlib's default font

后端 未结 4 1695
粉色の甜心
粉色の甜心 2020-12-14 16:26

I\'m trying to change matplotlib\'s default font to Helvetica Neue. On my Mac with EPD/Canopy everything worked fine some time ago.

Trying to do the same on ubuntu

4条回答
  •  情书的邮戳
    2020-12-14 16:39

    Ubuntu 14.04 LTS

    Upload the fonts

    sudo cp NotoSansKR-Regular.otf /usr/share/fonts/
    

    Update the cache of font

    sudo fc-cache -fv
    

    You can check the font list

    fc-list
    

    Restart ipython, etc. Check the font list

    [f.name for f in matplotlib.font_manager.fontManager.ttflist]
    

    Take a your font name

    import matplotlib.pyplot as plt
    from matplotlib import rcParams
    rcParams['font.family'] = 'Noto Sans Korean'
    

    Draw

    plt.title(u'한글 제목')
    plt.xlabel(u'한글 축 이름')
    plt.plot(range(5))
    

提交回复
热议问题