python调用Matplotlib绘制分布点图


Posted in Python onOctober 18, 2019

Python调用Matplotlib代码绘制分布点,供大家参考,具体内容如下

  • 绘制点图的目的
  • Matplotlib简介
  • 代码
  • 截图

1.绘制点图的目的

我们实验室正在做关于人脸识别的项目,其中在人脸检测后,会有些误检的图片,但是其中就有很多不符合的。很明显的是从图片大小,就可以过滤掉一部分。老大交给我的工作,就是通过绘制图片width,height的分布图,来找到一个合理的阈值。

2.Matlablib简介

Matplotlib是一个Python的图形框架

下面是官网的例子

Matplotlib example

3.代码如下

import matplotlib.pyplot as plt
from numpy.random import rand
import numpy
import os
import cv2

#setting plt
plt.xlim(xmax=500,xmin=0)
plt.ylim(ymax=500,ymin=0)
plt.xlabel("height")
plt.ylabel("width")


path_1 = r'D:\zhangjichao\view\path_1'


x = []
y = []
files = os.listdir(path_1)
for f in files:
  img = cv2.imread(path_1 + '\\' + f)
  x.append(img.shape[0])
  y.append(img.shape[1])
plt.plot(x,y,'ro',color='red',label='path_1')

path_2 = r'D:\zhangjichao\view\path_2'

x = []
y = []
files = os.listdir(path_2)
for f in files:
  img = cv2.imread(path_2 + '\\' + f)
  x.append(img.shape[0])
  y.append(img.shape[1])
plt.plot(x,y,'ro',color='red',label='path_2')

path_3 = r'D:\zhangjichao\view\path_3'


x = []
y = []
files = os.listdir(path_3)
for f in files:
  img = cv2.imread(path_3 + '\\' + f)
  x.append(img.shape[0])
  y.append(img.shape[1])
plt.plot(x,y,'ro',color='red',label='path_3')

path_4 = r'D:\zhangjichao\view\path_4'

x = []
y = []
files = os.listdir(path_4)
for f in files:
  img = cv2.imread(path_4 + '\\' + f)
  x.append(img.shape[0])
  y.append(img.shape[1])
plt.plot(x,y,'ro',color='red',label='path_4')

yujing = r'D:\zhangjichao\view\xujing'

x = []
y = []
files = os.listdir(yujing)
for f in files:
  img = cv2.imread(yujing + '\\' + f)
  x.append(img.shape[0])
  y.append(img.shape[1])
plt.plot(x,y,'ro',color='green' , label='yujing')

#图例
plt.legend(loc='upper center', shadow=True, fontsize='x-large')
plt.grid(True)

#显示
plt.show()

4.显示结果

python调用Matplotlib绘制分布点图

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持三水点靠木。

Python 相关文章推荐
Python中的类学习笔记
Sep 23 Python
Python random模块常用方法
Nov 03 Python
Python中多线程及程序锁浅析
Jan 21 Python
python追加元素到列表的方法
Jul 28 Python
matplotlib绘制动画代码示例
Jan 02 Python
Python中的二维数组实例(list与numpy.array)
Apr 13 Python
Python用于学习重要算法的模块pygorithm实例浅析
Aug 16 Python
python如何查看微信消息撤回
Nov 27 Python
OpenCV+Python--RGB转HSI的实现
Nov 27 Python
python实现银行实战系统
Feb 26 Python
Python xlrd excel文件操作代码实例
Mar 10 Python
python数据抓取3种方法总结
Feb 07 Python
Python 异常处理Ⅳ过程图解
Oct 18 #Python
python库matplotlib绘制坐标图
Oct 18 #Python
python实现WebSocket服务端过程解析
Oct 18 #Python
django实现支付宝支付实例讲解
Oct 17 #Python
python通过实例讲解反射机制
Oct 17 #Python
python集合常见运算案例解析
Oct 17 #Python
Pandas聚合运算和分组运算的实现示例
Oct 17 #Python
You might like
php调用mysql数据 dbclass类
2011/05/07 PHP
PHP截取指定图片大小的方法
2014/12/10 PHP
php用ini_get获取php.ini里变量值的方法
2015/03/04 PHP
Laravel 5框架学习之Eloquent 关系
2015/04/09 PHP
php支持断点续传、分块下载的类
2016/05/02 PHP
ThinkPHP3.2.1图片验证码实现方法
2016/08/19 PHP
PHP验证码类ValidateCode解析
2017/01/07 PHP
微信接口生成带参数的二维码
2017/07/31 PHP
XENON基于JSON变种
2010/07/27 Javascript
Uglifyjs(JS代码优化工具)入门 安装使用
2020/04/13 Javascript
JavaScript判断变量是否为undefined的两种写法区别
2013/12/04 Javascript
angularjs表格ng-table使用备忘录
2016/03/09 Javascript
举例说明JavaScript中的实例对象与原型对象
2016/03/11 Javascript
JavaScript关联数组用法分析【概念、定义、遍历】
2017/03/15 Javascript
JS 组件系列之Bootstrap Table的冻结列功能彻底解决高度问题
2017/06/30 Javascript
简单实现jQuery上传图片显示预览功能
2020/06/29 jQuery
快速解决angularJS中用post方法时后台拿不到值的问题
2018/08/14 Javascript
[00:23]DOTA2群星共贺开放测试 25日无码时代来袭
2013/09/23 DOTA
Python使用回溯法子集树模板解决迷宫问题示例
2017/09/01 Python
Python+selenium 获取浏览器窗口坐标、句柄的方法
2018/10/14 Python
详解python websocket获取实时数据的几种常见链接方式
2019/07/01 Python
Python 3.8 新功能大揭秘【新手必学】
2020/02/05 Python
Java多线程实现四种方式原理详解
2020/06/02 Python
联想德国官网:Lenovo Germany
2018/07/04 全球购物
Booking.com亚太地区:Booking.com APAC
2020/02/07 全球购物
Shopping happy life西班牙:以最优惠的价格提供最好的时尚配饰
2020/03/13 全球购物
学前教育求职自荐信范文
2013/12/25 职场文书
同志主要表现材料
2014/08/21 职场文书
司机工作自我鉴定
2014/09/19 职场文书
一次性工伤赔偿协议书范本
2014/11/25 职场文书
2014年质检工作总结
2014/11/26 职场文书
给老婆的道歉信
2015/01/20 职场文书
启动Tomcat时出现大量乱码的解决方法
2021/06/21 Java/Android
mysql联合索引的使用规则
2021/06/23 MySQL
浅谈Redis位图(Bitmap)及Redis二进制中的问题
2021/07/15 Redis
如何解决goland,idea全局搜索快捷键失效问题
2022/04/03 Golang