Python調用Matplotlib繪製分布點圖__Python

來源:互聯網
上載者:User

Python調用Matplotlib代碼繪製分布點 繪製點圖的目的 Matplotlib簡介 代碼 截圖

1.繪製點圖的目的

我們實驗室正在做關於Face Service的項目,其中在臉部偵測後,會有些誤檢的圖片,但是其中就有很多不符合的。很明顯的是從圖片大小,就可以過濾掉一部分。老大交給我的工作,就是通過繪製圖片width,height的分布圖,來找到一個合理的閾值。

2.Matlablib簡介

Matplotlib是一個Python的圖形架構
下面是官網的例子
Matplotlib example

3.代碼如下

import matplotlib.pyplot as pltfrom numpy.random import randimport numpyimport osimport cv2#setting pltplt.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.顯示結果

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.