国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

python調用Matplotlib繪制分布點并且添加標簽

2020-02-15 21:34:59
字體:
來源:轉載
供稿:網友

本文實例為大家分享了Python調用Matplotlib繪制分布點添加標簽的具體代碼,供大家參考,具體內容如下

添加標簽的目的 代碼 截圖

目的

上文介紹了根據圖像的大小作為坐標來繪制分布點圖。老大又給了我一個任務,我繪制完,每次將圖保存,發給她,但是圖片中的點的坐標是不能顯示了,所以她讓我給每個點添加個label,而且label是該點的橫縱坐標。

代碼

import matplotlib.pyplot as pltfrom numpy.random import randimport numpyimport osimport cv2#setting pltplt.xlim(xmax=100,xmin=0)plt.ylim(ymax=100,ymin=0)plt.xlabel("height")plt.ylabel("width")path_1 = r'D:/zhangjichao/view/V7_scale_2/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/V7_scale_2/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/V7_scale_2/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/V7_scale_2/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/V7_scale_2/xujing_org_scale_2'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='xujing')for i in range(1,len(x)):  plt.text(x[i],y[i],str((x[i],y[i])), family='serif', style='italic', ha='right', wrap=True)plt.legend(loc='upper center', shadow=True, fontsize='x-large')plt.grid(True)plt.show()

截圖

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林站長站。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 潼南县| 石嘴山市| 诏安县| 文水县| 海安县| 上饶县| 长泰县| 永仁县| 武清区| 东兴市| 上思县| 淮阳县| 水富县| 简阳市| 泰安市| 曲阳县| 义乌市| 中方县| 来安县| 卓尼县| 庆元县| 清徐县| 句容市| 那曲县| 东宁县| 石阡县| 辉南县| 舒城县| 太和县| 文水县| 柳州市| 马鞍山市| 简阳市| 宁陵县| 佛坪县| 乐东| 通江县| 吴川市| 奉化市| 山阴县| 米泉市|