

解决Mac中anaconda作图中文异常显示的问题
source link: http://www.cnblogs.com/plaza-wyj/p/13171400.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

说明
本篇主要针对在MAC系统中Anaconda环境下,matplotlib显示不了中文的问题,提出解决Python绘图时中文显示的方法。
运行环境
macOS Mojave 10.14.6 Python 3.7.4 Anaconda Notebook 6.0.1
问题由来
使用matplotlib时作图显示不出中文,令人很别扭,
解决方法
1.在访达文件夹中搜索“Fonts”,进入字体资源库,找到Mac内置标准中文字体Arial Unicode,值得注意的是文件名并不是全名。
2.接下来需要在Anaconda中打印出所有字体全名,并找到中文字体全名为Arial Unicode MS。
代码如下:
import matplotlib font_list=sorted([f.name for f in matplotlib.font_manager.fontManager.ttflist]) for i in font_list: print (i)
结果如下:
3.程序加载自符库
代码如下:
plt.rcParams['font.family'] = ['Arial Unicode MS'] #正常显示中文 plt.rcParams['font.sans-serif'] = ['KaiTi']#作图的中文 plt.rcParams['font.serif'] = ['KaiTi']#作图的中文 plt.rcParams['axes.unicode_minus'] = False # 解决保存图像是负号'-'显示为方块的问题
最终结果
Recommend
-
8
React-Native 在iOS7 上显示异常的问题解决 ...
-
16
解决命令行中 Git 显示中文文件名乱码 2020-02-10 2020-12-10工具 ,
-
23
Git 中文显示编码问题解决 作者
-
9
解决 Antd 3 表格固定列在 Modal 模态框下显示异常的问题 2021.07.12进击的码农 0 48 公司某个项目主要采...
-
6
Jager · 8月6日 · 2016年linux · linux基础知识 ·
-
7
anaconda笔记:解决conda无法下载pytorch的问题 | 高深远的博客anaconda笔记:解决conda无法下载pytorch的问题 发表于 2020-02-22 | 更新于: 2020-02-26 | 分类于
-
3
V2EX › 程序员 Monterey 12.2.1 中文显示问题 Dogod37 · 16 小时 7 分钟前 · 355 次点击...
-
6
Mr.Feng BlogNLP、深度学习、机器学习、Python、Go解决Linux下git无法显示中文的问题解决Linux下git无法显示中文的问题。 在新系统上常常碰到 git...
-
11
Published Mar 20, 2022 解决 git status 显示中文的问题 这篇文章转载简化自 git status 显示中文和解决中...
-
5
html页面 ajax调用的数据显示异常或操作异常解决. 2024年 1月 一 二
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK