How to change fonts in matplotlib (python)?

后端 未结 5 1137
不思量自难忘°
不思量自难忘° 2020-11-29 20:26

It sounds as an easy problem but I do not find any effective solution to change the font (not the font size) in a plot made with matplotlib in python.

I found a coup

5条回答
  •  隐瞒了意图╮
    2020-11-29 20:40

    Say you want Comic Sans for the title and Helvetica for the x label.

    csfont = {'fontname':'Comic Sans MS'}
    hfont = {'fontname':'Helvetica'}
    
    plt.title('title',**csfont)
    plt.xlabel('xlabel', **hfont)
    plt.show()
    

提交回复
热议问题