• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

python调用Matplotlib绘制分布点图

python 搞代码 4年前 (2022-01-07) 25次浏览 已收录 0个评论

这篇文章主要为大家详细介绍了python调用Matplotlib绘制分布点图,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

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<em style="color:transparent">来源[email protected]搞@^&代*@码网</em>='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.显示结果

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持gaodaima搞代码网

以上就是python调用Matplotlib绘制分布点图的详细内容,更多请关注gaodaima搞代码网其它相关文章!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:python调用Matplotlib绘制分布点图

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址