matplotlib 显示中文
# --*-- coding: utf-8 --*--
from matplotlib.font_manager import FontProperties
import matplotlib.pyplot as plt font = FontProperties(fname=r"/usr/share/fonts/win/msyh.ttf", size=14)
fig = plt.figure(figsize=(6, 6)) x = [1, 2, 3, 4, 5, 6, 7, 8]
y = []
for i in x:
y.append(-(i * i) + i + 3) ax = fig.add_subplot(111)
ax.plot(x, y, label=u'我我问') plt.title(u'测试程序', fontproperties=font)
plt.xlabel(u'x轴', fontproperties=font)
plt.ylabel(u'y轴', fontproperties=font) plt.grid(True)
plt.legend(prop=font) # 要让lable也支持中文
plt.show()
http://hi.baidu.com/bithigher/item/b9ce6d85dc102adc98255fb7 感谢这篇文章
matplotlib 显示中文的更多相关文章
- matplotlib显示中文异常处理
matplotlib显示中文 [做个记录,方便以后使用] [一般导入方式] import matplotlib.pyplot as plt [效果图] [方式一]FontProperties impo ...
- 修改配置文件matplotlibrc,让Matplotlib显示中文
matplotlib默认不支持中文显示,网上的解决办法有好多种,但是大多数都是通过在代码中指定字体,虽然也能实现,但是多出那么几行代码让人觉得很恶心. 本文介绍一种通过修改配置文件matplotlib ...
- matplotlib 显示中文 与 latex冲突
如果在使用中文之前包含了使用latex的语法: mpl.rcParams['text.usetex'] = True 将不能正确显示含有中文的图片. 附 显示中文的方法: from matplotli ...
- matplotlib显示中文
[注意] 可能与本文主题无关,不过我还是想指出来:使用matplotlib库时,下面两种导入方式是等价的(我指的是等效,当然这个说法可以商榷:) import matplotlib.pyplot as ...
- python tips;matplotlib 显示中文
import numpy as npimport matplotlib.pyplot as pltimport matplotlib as mpl mpl.rcParams['axes.unicode ...
- matplotlib 显示中文问题
import matplotlib.pyplot as plt plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签plt.rcParams[' ...
- matplotlib显示中文字体
原始地址:http://zanyongli.i.sohu.com/blog/view/195716528.htm matplotlib 1.0.0版 对于3.0的可能不太适用,要注意语法结构! C:/ ...
- Ubuntu matplotlib显示中文乱码的解决方法
https://blog.csdn.net/huuinn/article/details/78968966
- python数据分析入门——matplotlib的中文显示问题&最小二乘法
正在学习<用python做科学计算>,在练习最小二乘法时遇到matplotlib无法显示中文的问题.查资料,感觉动态的加上几条语句是最好,这里贴上全部的代码. # -*- coding: ...
随机推荐
- ssi(Server Side Includes)介绍
Server Side Includes (SSI) is a simple interpreted server-side scripting language used almost exclus ...
- oracle Form Builer:ID_NULL Built-in
Description Returns a BOOLEAN va ...
- Linux查看磁盘块大小
首先,使用df命令查看所在磁盘 df -hT 显示: Filesystem Type Size Used Avail Use% Mounted on /dev/vda1 ext4 15G .1G 12 ...
- JavaScript无限极菜单
<!DOCTYPE html> <html> <head> <title> New Document </title> <meta c ...
- Linux的各种命令(android adb shell)
win+r 调出运行,输入CMD adb shell 进入手机的控制终端,相当于原生的Linux系统的各种操作. 当提示符为$符号,说明未获得超级管理员权限,输入su,可编程# adb kill-se ...
- 在 ServiceModel 客户端配置部分中,找不到引用协定“PmWs.PmWebServiceSoap”的默认终结点元素
System.Exception: ConfigManager.LoadConfigurationFromDb ServiceFactory.GetPmWebService 在 ServiceMode ...
- SQL Server系统表sysobjects介绍与使用(转)
SQL Server系统表sysobjects介绍与使用 关于SQL Server数据库的一切信息都保存在它的系统表格里.我怀疑你是否花过比较多的时间来检查系统表格,因为你总是忙于用户表格.但是,你可 ...
- Ext.Net学习笔记06:Ext.Net DirectEvents用方补充
在ASP.NET控件上面使用DirectEvents 我们在ASP.NET中实现无刷新的页面请求的时候,通常会用到UpdatePanel,现在Ext.Net为我们提供了另外一种渠道:通过DirectE ...
- Xcode 7 支持http请求info.plist设置
由于iOS9改用更安全的https,为了能够在iOS9中正常使用http发送网络请求,请在"Info.plist"中进行如下配置,否则影响SDK的使用. 1.找到项目中的 Info ...
- ReactNative-----环境搭建二(android)
一.初始化一个ReactNative项目 在指定目录运行命令:react-native init Vince(项目名称) //其过程就是在使用CLI工具构建项目, 命令行代码 F:\React> ...