#!/usr/bin/env python
# -*- coding:utf-8 -*-
from pylab import *
from numpy import *
import numpy # 数据点图-数据点平滑处理
def moveing_average(ineterval,window_size):
window=ones(int(window_size))/float(window_size)
return convolve(ineterval,window,'same') t=linspace(-4,4,100)
y=sign(t)+randn(len(t))*0.1
plot(t,y,'k.') y_av=moveing_average(y,10)
plot(t,y_av,'r') xlabel('time')
ylabel('value')
grid(True)
show() # 图2-一个为曲线图 一个为折线图
windows=['flat','hanning','hamming','bartlett','blackman'] def smooth(x,window_len=11,window='hanning'):
if x.ndim!=1:
print('ere') if x.size<window_len:
print('ee2') if window_len<3:
return x if not window in windows:
print('4') s=numpy.r_[x[window_len-1:0:-1],x,x[-1:-window_len:-1]] if window=='flat':
w=numpy.ones(window_len,'d')
else:
w=eval('numpy.'+window+'(window_len)')
y=numpy.convolve(w/w.sum(),s,mode='valid')
return y t=linspace(-4,4,100)
x=sign(t)
xn=x+randn(len(t))*0.1 y=smooth(x) ws=31
subplot(211)
plot(ones(ws)) for w in windows[1:]:
eval('plot('+w+'(ws))')
axis([0,30,0,1.1])
legend(windows)
title('smoothing') subplot(212)
plot(x)
plot(xn)
for w in windows[1:]:
plot(smooth(xn,10,w))
I=['original ','noise']
I.extend(windows)
legend(I) title('signal')
show()

python3绘图示例3(基于matplotlib:折线图等)的更多相关文章

  1. matplotlib常见绘图基础代码小结:折线图、散点图、条形图、直方图、饼图

    一.折线图 二.散点图 三.条形图 四.直方图 五.饼图 一.折线图折线图用于显示随时间或有序类别的变化趋势 from matplotlib import pyplot as plt x = rang ...

  2. 使用matplotlib绘图(一)之折线图

    # 使用matplotlib绘制折线图 import matplotlib.pyplot as plt import numpy as np # 在一个图形中创建两条线 fig = plt.figur ...

  3. python matplotlib 折线图

    1.绘制折线图,去上和右边框,显示中文 import numpy as np import matplotlib.pyplot as plt #plt.style.use('default') #pl ...

  4. matplotlib 折线图

    1.基本要点 # 导入模块 from matplotlib import pyplot as plt # x轴数据 x = range(2, 26, 2) # y轴数据 y = [15, 13, 14 ...

  5. 练习: bs4 简单爬取 + matplotlib 折线图显示 (关键词,职位数量、起薪)

    要看一种技术在本地的流行程度,最简单的就是找招聘网站按关键词搜索. 比如今天查到的职位数量是vue 1296个,react 1204个,angular 721个.国际上比较流行的是react,本地市场 ...

  6. matplotlib折线图

    绘制折线图:参考https://baijiahao.baidu.com/s?id=1608586625622704613           (3)近10年GDP变化的曲线图,及三次产业GDP变化的曲 ...

  7. python3绘图示例5(基于matplotlib:正弦图等)

    #!/usr/bin/env python# -*- coding:utf-8 -*- import numpy as npimport pylab as pyimport matplotlib as ...

  8. python3绘图示例4(基于matplotlib:箱线图、散点图等)

    #!/usr/bin/env python# -*- coding:utf-8 -*- from matplotlib.pyplot import * x=[1,2,3,4]y=[5,4,3,2] # ...

  9. python3绘图示例6-2(基于matplotlib,绘图流程介绍及设置等)

    #!/usr/bin/env python# -*- coding:utf-8 -*- import os import numpy as npimport matplotlib as mpltfro ...

随机推荐

  1. springcloud系列七 整合slueth,zipkin 分布式链路调用系统:

    首先在代码里面引入依赖: <dependency> <groupId>org.springframework.cloud</groupId> <artifac ...

  2. freemarker 定义公共header

    <#--公共顶部--> <#macro header title="默认文字" keywords="默认文字" description=&qu ...

  3. Pandas基本功能详解

    Pandas基本功能详解 Pandas  Pandas基本功能详解 |轻松玩转Pandas(2) 参考:Pandas基本功能详解 |轻松玩转Pandas(2)

  4. 75th LeetCode Weekly Contest Smallest Rotation with Highest Score

    Given an array A, we may rotate it by a non-negative integer K so that the array becomes A[K], A[K+1 ...

  5. ansible部署,规划

    部署管理服务器 第一步:先检查有没有ssh服务 [root@iZm5eeyc1al5vzh8bo57zyZ ~]# rpm -qf /etc/init.d/sshd openssh-server-5. ...

  6. shell脚本启动java程序

    #!/bin/bash ### 切换到工作目录 bin=$(cd `dirname ${0}`;pwd) cd ${bin} echo "bin [${bin}] .." ### ...

  7. environment与@ConfigurationProperties的关系 加载过程分析

    environment是在printBanner之前就初始化好了, 更在context创建之前, 已经加载application-xxxx.properties, System.properties, ...

  8. poj 1001 字符串乘法以及处理精度问题

    #include<iostream> #include<cstring> using namespace std; int main() { string r; int n,d ...

  9. my22_mydumper 使用总结

    1. mydumper 的安装依赖于mysql软件,要使用mydumper 则服务器上必须先安装mysql 2. mydumper 安装时会使用mysql软件的动态链接库文件,如果服务器上mysql版 ...

  10. 关于Yii2中的MVC中的视图总结(持续更新中)

    一.首先在控制器中,将处理好的数据发送给前台: $this->layout = 'base'; 这里填写视图的模板文件(可以不写这行代码,如果不写,默认为views/layouts/main.p ...