Matplotlib使用笔记----中文字体显示
2018-03-26 11:21
567 查看
1. 查询matplotlib系统中文字体
from matplotlib.font_manager import fontManager import os fonts = [font.name for font in fontManager.ttflist if os.path.exists(font.fname) and os.stat(font.fname).st_size>1e6] for font in fonts: print(font)
2. 设置字体显示中文
import matplotlib.pyplot as plt plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签 plt.rcParams['axes.unicode_minus']=False #用来正常显示负号 plt.title('中文')
3. 修改rcParams字体来实现
rcParams的属性:‘font.family’ 用于显示字体的名字
‘font.style’ 字体风格,正常’normal’ 或斜体’italic’
‘font.size’ 字体大小,整数字号或者’large’ ‘x-small’
import matplotlib.pyplot as plt import matplotlib matplotlib.rcParams['font.family'] = 'STSong' matplotlib.rcParams['font.size'] = 20 plt.title('中文')
4. matplotlib调用windows系统字体
只希望在某地方绘制中文字符,不改变别的地方的字体import matplotlib.pyplot as plt from matplotlib.font_manager import FontProperties font = FontProperties(fname=r"c:\windows\fonts\msyh.ttc", size=10) plt.title('中文标题',fontproperties=font)
相关文章推荐
- python画图包seaborn和matplotlib中文字体显示(针对windows系统,,使用ipython notebook)
- spyder下使用matplotlib绘图中文显示不出来-解决过程记录
- Linux/MacOS下matplotlib能正常显示的中文字体选择
- Python 3下使用Matplotlib工具画图,中文显示乱码的问题解决(修改配置文件)
- linux 下matplotlib 无法显示中文字体的问题
- python 使用matplotlib绘图中文显示成框框解决办法
- python matplotlib绘图使用中文字体
- matplotlib显示中文字体
- 使用matplotlib绘图时中文字体的解决方案
- matplotlib命令与格式:系统字体与显示中文
- Matplotlib的中文字体显示为方块的问题
- Python使用matplotlib绘图无法显示中文问题的解决方法
- networkx使用笔记(三)之好汉篇Matplotlib(4)
- Matplotlib中文显示的问题
- python matplotlib中文显示问题
- matplotlib输出图象的中文显示问题(转载)
- python中matplotlib绘图中文显示问题
- Matplotlib中文显示的问题
- python matplotlib plot 数据中的中文无法正常显示的解决办法
- Wing IDE 4.1使用笔记一修正一下框框字体显示不了中文