matplotlib中字体设置问题
2018-03-03 14:55
417 查看
在画hist图时直接windows本机的宋体指定路径
songTi = matplotlib.font_manager.FontProperties(fname=’C:\Windows\Fonts\simsun.ttc’)
传给相应的参数即可:
然而在画pie时就不可用了,搜索了相关文档得知,matplotlib的字体格式是ttf,win上的字体是ttc格式
1. 将ttc转换成ttf
2. 将生成的两个文件保存在/matplotlib/mpl_data/font/ttf文件夹下,如果生成的simsun-02.ttf和nsimsun-01.ttf,改成simsun.ttf和nsimsun.ttf即可
3. 删除字体缓存.matplotlib/文件夹下的所有文件及文件夹
songTi = matplotlib.font_manager.FontProperties(fname=’C:\Windows\Fonts\simsun.ttc’)
传给相应的参数即可:
songTi = matplotlib.font_manager.FontProperties(fname='C:\Windows\Fonts\simsun.ttc') plt.xticks(fontproperties=songTi,fontsize=12) plt.yticks(fontproperties=songTi,fontsize=12) plt.xlabel('x',fontproperties=songTi,fontsize=14) plt.ylabel('y',fontproperties=songTi,fontsize=14) plt.legend(prop=songTi,fontsize=12)
然而在画pie时就不可用了,搜索了相关文档得知,matplotlib的字体格式是ttf,win上的字体是ttc格式
1. 将ttc转换成ttf
2. 将生成的两个文件保存在/matplotlib/mpl_data/font/ttf文件夹下,如果生成的simsun-02.ttf和nsimsun-01.ttf,改成simsun.ttf和nsimsun.ttf即可
3. 删除字体缓存.matplotlib/文件夹下的所有文件及文件夹
import matplotlib matplotlib.rcParams['font.family'] = 'sans-serif' matplotlib.rcParams['font.sans-serif'] = 'NSimSun,Times New Roman'# 中文设置成宋体,除此之外的字体设置成New Roman
相关文章推荐
- Matplotlib 中文字体设置
- 使用matplotlib的示例:调整字体-设置colormap和colorbar
- 使用matplotlib的示例:调整字体-设置colormap和colorbar
- Matplotlib的中文字体显示为方块的问题
- ubuntu下matplotlib中文字体的设置
- matplotlib字体大小相关设置
- python matplotlib画图产生的Type 3 fonts字体没有嵌入问题
- python matplotlib 画图刻度、图例等字体、字体大小设置
- python matplotlib 中文字体设置
- python matplotlib 画图刻度、图例等字体、字体大小设置
- 使用matplotlib的示例:调整字体-设置刻度、坐标、colormap和colorbar等
- 用matplotlib绘制带误差的条形图及中英文字体设置
- python—matplotlib数据可视化实例注解系列-----设置标注字体样式(matplotlib颜色库)
- Python 利用matplotlib绘制热力图 correlation heatmap X,Y 坐标轴字体重叠显示问题,将字体进行旋转
- matplotlib 中文字体问题
- linux 下matplotlib 无法显示中文字体的问题
- 使用matplotlib的示例:调整字体-设置刻度、坐标、colormap和colorbar等
- 动态可视化 数据可视化之魅D3,Processing,pandas数据分析,科学计算包Numpy,可视化包Matplotlib,Matlab语言可视化的工作,Matlab没有指针和引用是个大问题
- python matplotlib imshow显示问题
- python 1: 解决linux系统下python中的matplotlib模块内的pyplot输出图片不能显示中文的问题