问题描述
这听起来像一个简单的问题,但我没有找到任何有效的解决方案来改变在python matplotlib作出的阴谋字体(而不是字体大小)。我发现了一些教程,通过修改matplotlib存储其默认字体的文件夹中的某些文件来更改matplotlib的默认字体 - 请参阅 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 couple of tutorials to change the default font of matplotlib by modifying some files in the folders where matplotlib stores its default font - see this blog post - but I am looking for a less radical solution since I would like to use more than one font in my plot (text, label, axis label, etc). Say you want Comic Sans for the title and Helvetica for the x label. 这篇关于如何更改matplotlib(python)中的字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
pre code $ csfont = {'fontname':'Comic Sans MS'}
hfont = {'fontname':'Helvetica'}
plt.title('title',** csfont)
plt.xlabel('xlabel',** hfont)
plt .show()
csfont = {'fontname':'Comic Sans MS'}
hfont = {'fontname':'Helvetica'}
plt.title('title',**csfont)
plt.xlabel('xlabel', **hfont)
plt.show()