当前位置: 代码迷 >> 综合 >> matplotlib显示中文代码
  详细解决方案

matplotlib显示中文代码

热度:21   发布时间:2024-02-20 00:14:52.0

 

from matplotlib.font_manager import FontProperties
#matplotlib图片中不支持中文,需导入字体的路径,字体默认在此路径
font_set = FontProperties(fname=r"c:\windows\fonts\simsun.ttc", size=12) 
#matplotlib找不到字体,需要自行设置一下
plt.rcParams['font.sans-serif']=['SimHei']