python調(diào)用Matplotlib繪制分布點(diǎn)圖
Python調(diào)用Matplotlib代碼繪制分布點(diǎn),供大家參考,具體內(nèi)容如下
- 繪制點(diǎn)圖的目的
- Matplotlib簡介
- 代碼
- 截圖
1.繪制點(diǎn)圖的目的
我們實(shí)驗(yàn)室正在做關(guān)于人臉識(shí)別的項(xiàng)目,其中在人臉檢測(cè)后,會(huì)有些誤檢的圖片,但是其中就有很多不符合的。很明顯的是從圖片大小,就可以過濾掉一部分。老大交給我的工作,就是通過繪制圖片width,height的分布圖,來找到一個(gè)合理的閾值。
2.Matlablib簡介
Matplotlib是一個(gè)Python的圖形框架
下面是官網(wǎng)的例子
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.顯示結(jié)果

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
python 從遠(yuǎn)程服務(wù)器下載東西的代碼
python實(shí)現(xiàn)從遠(yuǎn)程服務(wù)器下載東西的代碼,有需要的朋友可以參考下2013-02-02
Python 快速把多個(gè)元素連接成一個(gè)字符串的操作方法
join() 方法一個(gè)用于將序列中的元素以指定的分隔符連接成一個(gè)字符串的方法,這個(gè)方法通常用于字符串操作,這篇文章主要介紹了Python 快速把多個(gè)元素連接成一個(gè)字符串的方法,需要的朋友可以參考下2024-06-06
使用Python在PowerPoint演示文稿之間復(fù)制樣式
在專業(yè)演示文稿設(shè)計(jì)與制作領(lǐng)域,多場(chǎng)演示間保持一致性至關(guān)重要,在PowerPoint演示文稿之間復(fù)制幻燈片母版成為了一項(xiàng)關(guān)鍵技巧,本文中,我們將探討如何使用Python在不同的PowerPoint演示文稿之間復(fù)制幻燈片母版,提升演示文稿創(chuàng)作流程的效率與美觀度,需要的朋友可以參考下2024-05-05
關(guān)于python的縮進(jìn)規(guī)則的知識(shí)點(diǎn)詳解
在本篇文章里小編給大家整理了關(guān)于python的縮進(jìn)規(guī)則的知識(shí)點(diǎn)詳解,有興趣的朋友們可以學(xué)習(xí)下。2020-06-06
使用python對(duì)excle和json互相轉(zhuǎn)換的示例
今天小編就為大家分享一篇使用python對(duì)excle和json互相轉(zhuǎn)換的示例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2018-10-10
Python實(shí)現(xiàn)的遠(yuǎn)程文件自動(dòng)打包并下載功能示例
這篇文章主要介紹了Python實(shí)現(xiàn)的遠(yuǎn)程文件自動(dòng)打包并下載功能,結(jié)合實(shí)例形式分析了Python使用spawn()方法執(zhí)行ssh、scp 命令實(shí)現(xiàn)遠(yuǎn)程文件的相關(guān)操作技巧,需要的朋友可以參考下2019-07-07

