#!/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. 【Leetcode】Combinations

    Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For exampl ...

  2. html td 限制 高度 和 宽度

    td 要设置成 display : block td 里面的span 自动换行.. <td style="max-width: 150px;overflow-y:scroll;disp ...

  3. C#获取单元格值(使用NPOI插件)

    /// <summary> /// 获取单元格的值 /// </summary> /// <param name="item"></par ...

  4. UVA1714 Keyboarding

    传送门 坑很多的一题 这里要感谢crk大佬提前帮我把所有的坑都踩了一遍...233 讲一下题目的意思: 给你一个神奇的 r*c 的键盘 (r,c<=50) 上面有大写的字母,数字,' - '号 ...

  5. 07-图5 Saving James Bond - Hard Version (30 分)

    This time let us consider the situation in the movie "Live and Let Die" in which James Bon ...

  6. Appium——appium之mac环境安装

    一.安装brew:Homebrew是一款Mac OS平台下的软件包管理工具执行:/usr/bin/ruby -e "$(curl -fsSL https://raw.githubuserco ...

  7. asp.net core WebAPI学习以及 发布(***入门学习)

    A asp.net Core 系列[一]——创建Web应用 asp.net Core 系列[二]—— 使用 ASP.NET Core 和 VS2017 for Windows 创建 Web API a ...

  8. PHP、thinkPHP5.0开发网站文件管理功能(二)删除文件

    1.is_dir():检查指定的文件是否是目录 2.scandir():返回指定目录中的文件和目录数组 3.unlink():删除文件,如果删除的文件不存在会报错,加@抑制报错 public func ...

  9. Storm与Spark区别

    Storm擅长于动态处理大量实时生产的小数据块,概念上是将小数据量的数据源源不断传给过程: Spark擅长对现有的数据全集做处理,概念是将过程传给大数据量的数据. 二者设计思路相反.Storm侧重于处 ...

  10. tomcat入门(一)几种常见的使用tomcat部署项目的方式

    1.常规方式部署 直接把web项目复制到tomcat安装目录下的%Tomcat_Home%/webapps/{web项目} 2.使用控制台进行部署 若一个web应用结构为D:\workspace\We ...