seaborn在mac中中文字体问题

seaborn在mac中无论用 anaconda,还是直接shell的 python运行,都会涉及到中文的显示。

用了很多办法。

1.修改matplotlib的设置,然后程序里设置

2.直接指定字体文件,设置在matplotlib显示里。

 

myfont = matplotlib.font_manager.FontProperties(fname="/Library/Fonts/SimHei.ttf")#"/Library/Fonts/Songti.ttc")
plt.plot(......=myfont)

可以让matplotlib搞定。

3.seaborn搞定办法

首先复制matplotlib文件到当前目录

 

cp /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/mpl-data/matplotlibrc ~/.matplotlib/.

在程序里加入如下:

myfont = matplotlib.font_manager.FontProperties(fname="/Library/Fonts/SimHei.ttf")#"/Library/Fonts/Songti.ttc")

sns.set(font=myfont.get_name())

 

轻松搞定。

关注微信公众号,获取更多精彩:

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值