python調(diào)用Matplotlib繪制分布點圖
Python調(diào)用Matplotlib代碼繪制分布點,供大家參考,具體內(nèi)容如下
- 繪制點圖的目的
- Matplotlib簡介
- 代碼
- 截圖
1.繪制點圖的目的
我們實驗室正在做關(guān)于人臉識別的項目,其中在人臉檢測后,會有些誤檢的圖片,但是其中就有很多不符合的。很明顯的是從圖片大小,就可以過濾掉一部分。老大交給我的工作,就是通過繪制圖片width,height的分布圖,來找到一個合理的閾值。
2.Matlablib簡介
Matplotlib是一個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)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
python socket通信編程實現(xiàn)文件上傳代碼實例
這篇文章主要介紹了python socket通信編程實現(xiàn)文件上傳代碼實例,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2019-12-12Python matplotlib實現(xiàn)圖表主題變換示例詳解
在畫圖的時候如果出現(xiàn)與圖表的顏色沖突或者看不清坐標軸的情況,這時候可以通過更換坐標軸風格來解決,本文將為大家詳細介紹如何利用matplotlib實現(xiàn)圖表的主題樣式變換,需要的可以參考一下2022-03-03pyecharts中from pyecharts import options
本文主要介紹了pyecharts中from pyecharts import options as opts報錯問題以及解決辦法,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-07-07