Python calls Matplotlib to draw a distribution point graph __python

Source: Internet
Author: User

Python calls the Matplotlib code to draw the point map of the distribution point matplotlib Introduction code screenshot

1. The purpose of drawing a point chart

Our lab is doing a face recognition project, in which there are some false-check pictures after the face detection, but there are a lot of things that don't match. It is obvious from the size of the picture, you can filter out a part. The boss gave me the job, that is, by drawing a picture of the distribution map, to find a reasonable threshold value. width,height

2.Matlablib Introduction

Matplotlib is a Python graphics frame
Here is an example of the official website
matplotlib Example

3. The code is as follows

Import Matplotlib.pyplot as PLT from numpy.random import rand import numpy import os import cv2 #setting plt Plt.xlim (xma x=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.sh

Ape[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_4For 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. Display Results

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.