不需要用fc-list,找到字体路径,解决matplotlib中文显示问题。
1.找到字体路径
mac字体的路径一般都是在:/System/Library/Fonts 下
如果不放心可在:访达>字体册>简体中文>在访达中显示>显示简介>位置,在将字体名称输入进去。
这样就已经找到字体的路径了~
2.解决matplotlib显示中文字体问题
2.1这里注意将fname=“ ”中的字体路径更改为自己电脑下的路径
from matplotlib import font_manager
my_font = font_manager.FontProperties(fname="/System/Library/Fonts/STHeiti Medium.ttc")
2.2在设置轴刻度中,增加fontporperties=my_font
plt.xticks(list(x)[::3],_xtick_labels[::3],rotation=45,fontproperties=my_font)
这样就完美解决了~