matplotlib 与 seaborn 中出现中文乱码的解决方法
2017-11-06 14:49
661 查看
Linux、Mac osx 系统中,出现 matplotlib 或 seaborn 绘图中有中文乱码的情形,可以考虑使用以下方式处理:
到 anaconda 的 matplotlib 中查看是否有 simhei.ttf 字体:
如果没有,从 windows 中用 everything 搜索全局文件,找到 simhei.ttf,并将其上传到linux 的 matplotlib 的 fonts/ttf 文件夹
修改配置文件~/anaconda3/lib/python3.5/site-packages/matplotlib/mpl-data/matplotlibrc 文件,
将该文件拷贝到.cache/matplotlib 目录下,并找到以下两行,改为如下:
(linux)删除~/.cache/matplotlib/目录下的 fonts cache list
代码设置 matplotlib 和 seaborn 的环境
参考:
https://github.com/mwaskom/seaborn/issues/1009
http://www.th7.cn/Program/Python/201704/1156781.shtml
到 anaconda 的 matplotlib 中查看是否有 simhei.ttf 字体:
cd ~/anaconda3/lib/python3.5/site-packages/matplotlib/mpl-data/fonts/ttf ls -al | grep simhei
如果没有,从 windows 中用 everything 搜索全局文件,找到 simhei.ttf,并将其上传到linux 的 matplotlib 的 fonts/ttf 文件夹
修改配置文件~/anaconda3/lib/python3.5/site-packages/matplotlib/mpl-data/matplotlibrc 文件,
将该文件拷贝到.cache/matplotlib 目录下,并找到以下两行,改为如下:
font.family : sans-serif font.sans-serif : simhei, Bitstream Vera Sans, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif
(linux)删除~/.cache/matplotlib/目录下的 fonts cache list
代码设置 matplotlib 和 seaborn 的环境
import matplotlib as mpl mpl.rcParams['font.sans-serif'] = ['simhei'] mpl.rcParams['font.serif'] = ['simhei'] import seaborn as sns sns.set_style("darkgrid",{"font.sans-serif":['simhei','Droid Sans Fallback']})
参考:
https://github.com/mwaskom/seaborn/issues/1009
http://www.th7.cn/Program/Python/201704/1156781.shtml
相关文章推荐
- matplotlib中文乱码解决方法
- Python 3下Matplotlib画图中文显示乱码的解决方法
- 真·matplotlib中文乱码问题·解决方法
- ubuntu系统下matplotlib中文乱码问题的解决方法
- matplotlib中文乱码解决方法
- Python 3下Matplotlib画图中文显示乱码的解决方法
- matplotlib中文乱码解决方法
- matplotlib中文乱码解决方法
- Ubuntu下matplotlib中文无法显示的解决方法
- 解决matplotlib中文乱码问题(Windows)
- 解决matplotlib中文乱码问题(Windows)
- 关于使用pyinstaller 打包带有matplotlib 等出现UnicodeDecodeError解决方法
- matplotlib图例中文乱码解决
- python使用matplotlib画图出现中文乱码
- Matplotlib下出现乱码的两种解决办法--FontProperties
- 解决matplotlib绘图中显示中文乱码的问题
- 解决matplotlib中文乱码问题
- Matplotlib中文乱码解决办法
- 彻底解决matplotlib中文乱码问题
- Python 3下使用Matplotlib工具画图,中文显示乱码的问题解决(修改配置文件)