python在Mac环境下,matplotlib中文乱码解决
mac有两个放置字体的路径,
/System/Library/Fonts/ 和 /Library/Fonts/
看了发现 /Library/Fonts/ 底下只有一个ttc文件,试了发现不行。
而/System/Library/Fonts/ 底下一大堆,从里面选了一个STHeiti Light,直接解决了。
import matplotlib
from matplotlib.font_manager import FontProperties
font = FontProperties(fname=r'/System/Library/Fonts/STHeiti Light.ttc')
matplotlib.rcParams["font.family"