matplotlib.plot显示中文有问题
来源:互联网 发布:58 程序员兼职 编辑:程序博客网 时间:2024/06/07 08:56
- matplotlib.plot显示中文有问题,解决方法:
- # -*- coding: utf-8 -*-
- import numpy as np
- import matplotlib
- import matplotlib.pyplot as plt
- myfont = matplotlib.font_manager.FontProperties(fname='C:/Windows/Fonts/simhei.ttf') #Windows系统,黑体
- #myfont = matplotlib.font_manager.FontProperties(fname='/home/Fonts/simhei.ttf') #Linux系统,黑体
- matplotlib.rcParams['axes.unicode_minus'] = False #坐标可显示‘—’号
- a = np.arange(0, 5, 0.01)
- plt.plot(a, 5*a)
- plt.axis([-1,5,-1,25]) #设置xy轴范围
- plt.xlabel(u'中文x坐标',fontproperties=myfont)
- plt.ylabel(u'英文y坐标',fontproperties=myfont)
- plt.show()
对于Linux系统, 直接从Windows系统的C:/Windows/Fonts/ 中将字体拷贝至所需目录,如/home/Fonts/, 然后修改fname路径。如:
myfont = matplotlib.font_manager.FontProperties(fname='/home/Fonts/simhei.ttf') #Linux系统,黑体
阅读全文
0 0
- matplotlib.plot显示中文有问题
- 解决mac上matplotlib(plot)无法显示中文的问题 (Python)
- matplotlib显示中文问题
- matplotlib显示中文问题
- matplotlib中文显示问题
- Matplotlib中文显示的问题
- Matplotlib中文显示的问题
- python matplotlib中文显示问题
- python matplotlib中文显示问题
- python matplotlib中文显示问题
- Matplotlib输出中文显示问题
- Matplotlib中文显示的问题
- Matplotlib输出中文显示问题
- python matplotlib中文显示问题
- matplotlib图例中文显示问题
- Matplotlib输出中文显示问题
- matplotlib中文显示方块问题
- python matplotlib中文显示问题
- MyBatis框架
- select count(1) from user where id=2
- hibernate事务管理
- 树状数组讲解(转载)_清晰详细版
- 链表倒数第k个节点
- matplotlib.plot显示中文有问题
- 给初学者的RxJava2.0教程(二)
- 基于GPUImage的多滤镜rtmp直播推流
- makefile须知
- web项目部署与上线
- Protocolbuffer配置
- 汉诺塔问题
- Eclipse设置不格式化注释
- 【算法题】星际穿越