matpilot基础
matpilot
- 一、折线
- 二、条形
- 三、多条形
- 四、直方图
- 五、散点
一、折线
import random
from matplotlib import pyplot
from matplotlib import font_managermy_font = font_manager.FontProperties(fname="/usr/share/fonts/truetype/arphic/uming.ttc")
fig = pyplot.figure(figsize=(20, 8), dpi=80)x = range(0, 120)
y = [random.randint(20, 35) for i in range(120)]
yy = [random.randint(20, 35) for i in range(120)]
pyplot.plot(x, y, label="第一", color="orange", linestyle=":")
pyplot.plot(x, yy, label="第二", color="cyan", linestyle="-.")_x = list(x[::10])
labelx = ["1选0:{}".format(i) for i in range(120)]
pyplot.xticks(_x, labelx[::10], rotation=90, fontproperties=my_font)
pyplot.yticks(range(min(y), max(y) + 1))
pyplot.xlabel("shijian")
pyplot.ylabel("wendu")
pyplot.title("bianhua")
pyplot.grid(alpha=0.1, linestyle="-.")
pyplot.legend(prop=my_font, loc='upper right')
pyplot.show()
二、条形
from matplotlib import pyplot
from matplotlib import font_manager
my_font = font_manager.FontProperties(fname="/usr/share/fonts/truetype/arphic/uming.ttc")a = ["隐\n藏着", "njc", "qym", "lbz", "mrb", "zx", "tcm"]
b = [30.2, 29.6, 15.8, 16.8, 45.1, 46.7, 47.0]
pyplot.figure(figsize=[20, 8], dpi=80)
# pyplot.bar(range(len(a)), b, width=0.3)
pyplot.barh(range(len(a)), b, height=0.8)
pyplot.yticks(range(len(a)), a, rotation=0, fontproperties=my_font)
# pyplot.xticks(range(len(a)), a, rotation=90, fontproperties=my_font)
pyplot.grid(alpha=0.3)
pyplot.show()
三、多条形
from matplotlib import pyplot
from matplotlib import font_manager
my_font = font_manager.FontProperties(fname="/usr/share/fonts/truetype/arphic/uming.ttc")a = ["隐藏着", "njc", "qym", "mrb"]
b_16 = [15746, 312, 4497, 319]
b_15 = [12357, 156, 2045, 168]
b_14 = [2358, 399, 2358, 362]
pyplot.figure(figsize=[20, 8], dpi=80)
x_14 = list(range(len(a)))
x_15 = [i+0.2 for i in x_14]
x_16 = [i+0.2*2 for i in x_14]
pyplot.bar(range(len(a)), b_14, width=0.2, label="9月14日")
pyplot.bar(x_15, b_15, width=0.2, label="9月15日")
pyplot.bar(x_16, b_16, width=0.2, label="9月16日")
pyplot.legend(prop=my_font)
pyplot.xticks(x_15, a, rotation=0, fontproperties=my_font)
pyplot.show()
四、直方图
import matplotlib.pyplot as plt
from matplotlib import pyplot
from matplotlib import font_manager
import random
my_font = font_manager.FontProperties(fname="/usr/share/fonts/truetype/arphic/uming.ttc")a = [0]*250
for i in range(0, 250):a[i] = random.randint(80, 150)
d = 5
num_bins = (max(a)-min(a))//d#pyplot.hist(a, num_bins)
pyplot.hist(a, num_bins, normed=True)plt.xticks(range(min(a), max(a)+d, d))
plt.grid()
pyplot.show()
from matplotlib import pyplot
from matplotlib import font_managerinterval = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 60, 90]
width = [5, 5, 5, 5, 5, 5, 5, 5, 5, 15, 30, 60]
quantity = [836, 2737, 3723, 3926, 3596, 1438, 3273, 642, 824, 613, 215, 47]
_x = [i-0.5 for i in range(13)]
_xtick = interval + [150]
print(_xtick)
pyplot.xticks(_x, _xtick)
pyplot.bar(range(len(quantity)), quantity, width=1)
pyplot.grid()
pyplot.show()
五、散点
from matplotlib import pyplot
from matplotlib import font_manager
my_font = font_manager.FontProperties(fname="/usr/share/fonts/truetype/arphic/uming.ttc")y_3 = [11, 17, 16, 11, 12, 11, 12]
y_10 = [26, 26, 28, 19, 21, 17, 16]
x_3 = range(1, len(y_10)+1)
x_10 = range(10, len(y_10)+10)
pyplot.figure(figsize=[20, 8], dpi=80)
pyplot.scatter(x_3, y_3, label = "3月")
pyplot.scatter(x_10, y_10, label = "10月")
_x = list(x_3) + list(x_10)
_xtick_labels = ["3月{}日".format(i) for i in x_3]
_xtick_labels += ["10月{}日".format(i-9) for i in x_10]
print(_xtick_labels)
pyplot.xticks(_x[::1], _xtick_labels[::1], rotation=45, fontproperties=my_font)
pyplot.xlabel("时间", fontproperties=my_font)
pyplot.ylabel("温度", fontproperties=my_font)
pyplot.title("标题", fontproperties=my_font)
pyplot.legend(loc="upper left",prop=my_font)
pyplot.show()
matpilot基础相关推荐
- java入门 慕路径,Java入门基础知识总结学习教程大全【必看经典】
类型的表达式,是循环条件,表达式3是党执行了一遍循环之后,修改控制循环的变量值. ??? for语句的执行过程是这样的:首先计算表达式1,完成必要的初始化工作:然后判断表达式2的值,如果表达式的值为t ...
- 提交表单自动刷新_Web自动化测试:元素的基础操作和浏览器基础操作
上一节,我们了解了如何定位元素,其实也有涉及对于元素的操作,这一节我们就详细的介绍一下对于元素的操作和对于浏览器的一些操作 一.对于元素的基础操作: clear():清除输入框内的文本 send_ke ...
- java mybatis基础
java mybatis基础 1.1 什么是mybatis? mybatis是一个优秀的持久层框架. 避免几乎所有的JDBC代码和手动设置参数以及获取结果集的过程. 可以使用简单的xml或者注解来配置 ...
- 【J2SE】学习基础
Java基础 语法基础 OO Exception Array 基础类 I/O Stream Collection/Generic Thread TCP/UDP GUI Meta Data Regula ...
- 【Linux系统】基础总结
我不太清楚运维部门具体是做什么的,就接触过一点点运维部门! 也就是是知道他们负责管理服务器,管理网络,管理项目部署 偶尔自己需要部署,不得不接触一些linux命令.简单总结一些基础 linux系统发展 ...
- 【Java 2 Platform Enterprise Edition】基础
问题1:为什么java是无关平台? 你之前用C或者C++写的源代码,编译好后,换一种操作系统,可能就执行不了了.因为新的操作系统不识别,你需要修改你的源码,并在新的操作系统上重新编译才能运行,比如Wi ...
- SpringCloud Alibaba微服务实战(一) - 基础环境搭建
说在前面 Spring Cloud Alibaba 致力于提供微服务开发的一站式解决方案.此项目包含开发分布式应用微服务的必需组件,方便开发者通过 Spring Cloud 编程模型轻松使用这些组件来 ...
- Redis概述和基础
Redis 1.NoSQL NoSQL = Not Only SQL(不仅仅是SQL) 泛指非关系型数据库的,随着web2.0互联网的诞生!传统的关系型数据库很难对付web2.0时代!尤其是超大规模的 ...
- pass基础架构分析
pass基础架构分析 Relay 和 TVM IR,包含一系列优化passes,可提高模型的性能指标,如平均推理,内存占用,或特定设备的功耗.有一套标准优化,及特定机器学习的优化,包括常量折叠,死代码 ...
最新文章
- 『干货』分享你最喜欢的技巧和提示(Xcode,objective-c,swift,c...等等)
- Winform中使用FastReport的PictureObject时通过代码设置图片源并使Image图片旋转90度
- 我python写的闭包为什么效率很低_GitHub - llzhi001/interview_python_practice: interview 面试题 CS-Notes之ME-技术总结...
- 软件测试工程师和WGT,软件系统测试(WGT)工程师---ATK
- percona-toolkit(pt工具)使用总结
- Python解压压缩包
- 师傅带徒弟 但是不能 教会徒弟饿死师傅!
- 关于ugui界面显示隐藏的优化
- 使用Windows中的字体生成点阵字库
- 如何运用SWOT分析法
- java 将5mb以内图片压缩至200kb以下
- Linux 磁盘操作管理
- directdraw(directdraw怎么开启)
- Repeater的 Items属性、Items里面的控件有几个?
- 企业邮箱支持通过手机号登录邮箱
- STM32三菱FX1N,FX2N,FX3U,PLC方案 可以直接上传下载梯形图,在线监控,具有称重功能,数码管功能,可以做到10路模拟量
- 干掉PPT!现场编码的职级晋升答辩你参加过么?
- Mac 删除系统自带的 ABC 默认输入法
- MyEclipse(不论版本是啥)卸载后重新安装,提示:拷贝到计算机时出错;问题解决方案:
- 【C语言】——删除多余的空格