python中画图时x,y轴名称出现中文乱码的解决方法
#-*- coding:utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
#k与客户端处理时间的值之间的关系
x=range(2,51,2)
y1=[5.393128497232703, 9.57638681757734, 13.828038570286598, 17.88060602988053, 22.943959373243686, 26.892428234326893, 30.47858918562443, 34.60601930629202, 39.37536486605157, 44.707097894669666, 49.00997474201327, 53.05414464511094, 57.211619356802395, 61.20307126632874, 65.41988871060431, 69.69244104837131, 73.63465839518058, 78.46661240393595, 82.84478734120208, 86.80821629368924, 90.99962335403121, 94.58170993534843, 98.88147657656751, 102.69580224812181, 107.41566442865962]
y2=[9.663068261869904, 17.801700100864338, 27.31914851265208, 35.79629518468646, 45.13319613177378, 51.95947650254608, 61.117229577687205, 68.43660202517938, 76.67479156176297, 86.81101547918409, 94.77081046684226, 103.12392211919445, 111.47750030247012, 120.47252739391641, 128.45760835724428, 136.5147527961354, 144.73356574866335, 153.792165453029, 162.01950037025804, 170.3556925013953, 179.1485561956748, 186.67093179599007, 195.2194576982225, 205.29080271621825, 213.35460299616648]
p2=plt.plot(x,y2,label='NA',color='black',marker='d',linewidth=1,mec='black', mfc='orange')
p3=plt.plot(x,y1,label='DA',color='black',marker='o',linewidth=1,mec='black',mfc='g')
plt.xlabel('k')
font_set = FontProperties(fname=r"c:\windows\fonts\simsun.ttc", size=12)
plt.ylabel(u'整个过程的时间消耗 (ms)',fontproperties=font_set)
plt.legend()
plt.show()
在3维画图时同样也遇到过这个问题,查找许多资料都是操作Lib包中的文件,感觉比较麻烦,于是就想出了一个特别无脑的操作,把想要表达的中文直接转ASCII码,直接上在线转码网址:http://tool.oschina.net/encode?type=3
#-*- coding:utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
#k与客户端处理时间的值之间的关系
x=range(2,51,2)
y1=[5.393128497232703, 9.57638681757734, 13.828038570286598, 17.88060602988053, 22.943959373243686, 26.892428234326893, 30.47858918562443, 34.60601930629202, 39.37536486605157, 44.707097894669666, 49.00997474201327, 53.05414464511094, 57.211619356802395, 61.20307126632874, 65.41988871060431, 69.69244104837131, 73.63465839518058, 78.46661240393595, 82.84478734120208, 86.80821629368924, 90.99962335403121, 94.58170993534843, 98.88147657656751, 102.69580224812181, 107.41566442865962]
y2=[9.663068261869904, 17.801700100864338, 27.31914851265208, 35.79629518468646, 45.13319613177378, 51.95947650254608, 61.117229577687205, 68.43660202517938, 76.67479156176297, 86.81101547918409, 94.77081046684226, 103.12392211919445, 111.47750030247012, 120.47252739391641, 128.45760835724428, 136.5147527961354, 144.73356574866335, 153.792165453029, 162.01950037025804, 170.3556925013953, 179.1485561956748, 186.67093179599007, 195.2194576982225, 205.29080271621825, 213.35460299616648]
p2=plt.plot(x,y2,label='NA',color='black',marker='d',linewidth=1,mec='black', mfc='orange')
p3=plt.plot(x,y1,label='DA',color='black',marker='o',linewidth=1,mec='black',mfc='g')
plt.xlabel('k')
font_set = FontProperties(fname=r"c:\windows\fonts\simsun.ttc", size=12)
plt.ylabel(u'\u6574\u4e2a\u8fc7\u7a0b\u7684\u65f6\u95f4\u6d88\u8017 (ms)',fontproperties=font_set)
plt.legend()
plt.show()
python中画图时x,y轴名称出现中文乱码的解决方法相关推荐
- python画图y轴在右侧_解决python中画图时x,y轴名称出现中文乱码的问题
如下所示: #-*- coding:utf-8 -*- import numpy as np import matplotlib.pyplot as plt from matplotlib.font_ ...
- python画xy轴折线在拐点处加汉字_解决python中画图时x,y轴名称出现中文乱码的问题...
如下所示: #-*- coding:utf-8 -*- import numpy as np import matplotlib.pyplot as plt from matplotlib.font_ ...
- VS中编写Qt项目时,提取ts文件出现中文乱码的解决方法(填坑)
总第84篇 本篇主要总结一个在开发过程中遇到的问题,方便以后参考,也方便后来者可以避免这个坑. 1.问题的产生 一般在做C++开发过程中,都会选择使用Visual Studio+Qt AddIn的环境 ...
- Activiti保存.png 流程图片文件且解决idea中保存图片时显示中文乱码的解决方法
Activiti保存.png 流程图片文件且解决idea中保存图片时显示中文乱码的解决方法 Eclipse 工具中的操作 流程图片生成的两种方式: 使用 activiti-designer 设计流程图 ...
- python中使用pip安装报错:Fatal error in launcher... 解决方法
python中使用pip安装报错:Fatal error in launcher... 解决方法 参考文章: (1)python中使用pip安装报错:Fatal error in launcher.. ...
- mysql脚本执行中文乱码_MySQL从命令行导入SQL脚本时出现中文乱码的解决方法
本文实例讲述了MySQL从命令行导入SQL脚本时出现中文乱码的解决方法.分享给大家供大家参考,具体如下: 在图形界面管理工具 MySql Query Browser中打开脚本(脚本包括建库.建表.添加 ...
- Latex打开tex文件时产生中文乱码的解决方法
中文兼容方法(能保证编译成功) 引用文章链接:Latex文件分别用Texwork和Winedt打开时,产生中文乱码的解决方法 - 大白技术控 - 博客园 \usepackage{CJK}\begin{ ...
- RStudio控制台(console)中出现少量中文乱码的解决方法
RStudio控制台(console)中出现少量中文乱码的解决方法 参考文章: (1)RStudio控制台(console)中出现少量中文乱码的解决方法 (2)https://www.cnblogs. ...
- tomcat+SSH中遇到中文乱码的解决方法
最近开始又转向J2EE的开发.很久没用,重新熟悉. 本地环境ubuntu 12.13,mysql5.x,tomcat7.x,struts2.3.15.x,spring3.1.0,hibernate4. ...
最新文章
- python迭代计算_如何在Python中迭代坐标列表并计算它们之间的距离
- [python]目录及文件操作
- Python 为什么不支持 i++ 自增语法,不提供 ++ 操作符?
- spring 通过工厂方法配置Bean
- 数学之旅-不动点定理
- 深入理解IOC模式及Unity框架
- c#sdf数据库连接_如何连接并处理 sdf 数据库文件(便捷数据库处理)
- Python入门学习---第四天
- 阿里最新面试必备项之Java的String类,持续更新中!
- jstl视图_使用JSTL视图探索Spring Controller
- extJS 中 ext.data 介绍
- linux添加终端快捷键,linux 终端快捷键
- 计算机指令的操作码和地址,操作码和地址码
- Go 每日一库之 go-flags
- Kettle(三)Java定时调用.ktr文件
- 读书有益——》《断舍离·舍·做减法的勇气》
- Revit API 2018调试闪退
- 男生容易误解女生的几个行为(转载)
- 主机连接wifi时,虚拟机VMware如何连接网络
- 机器人笔记本清灰_小熏的编程日记 » 愉悦的小机器人调教经历(一):使用笔记本为HTC G4提供无线路由...