Python使用pylab庫實現(xiàn)繪制直方圖功能示例
本文實例講述了Python使用pylab庫實現(xiàn)繪制直方圖功能。分享給大家供大家參考,具體如下:
Python直方圖
#!/usr/bin/python # -*- coding: utf-8 -*- import pylab as pl dataFile = "dataList.txt" tempList = [] with open(dataFile,"r") as data: for everLine in data: arrEverLine = [float(index) for index in everLine.split()] tempList.append(arrEverLine[0]) pl.hist(tempList,100) pl.xlabel("直方圖標題", fontproperties='SimHei') pl.show()
dataList.txt內(nèi)容
14 2 1 0.5 0.5 0 1 0.5 1.5 18.5
19 2 2 0.5 1 0 1 0.5 0 21
19.5 2 1.5 2 0 0.5 2 0 1 20
17.5 1.5 1 1.5 2 0 1.5 0 0 18.5
19.5 2 2 2 0.5 0 1 0 0.5 19.5
16.5 2 0.5 1 0 0.5 0.5 0 0.5 19.5
15.5 2 1 1.5 0 0 1 0.5 1 17.5
13.5 1.5 1 1 2 0 2 0.5 2 20
14.5 2 1.5 2 0 0 1 0 2 18.5
16 2 2 1.5 1 0.5 1 0 2 19.5
。。。
輸出結(jié)果
更多關(guān)于Python相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Python數(shù)學運算技巧總結(jié)》、《Python字符串操作技巧匯總》、《Python編碼操作技巧總結(jié)》、《Python數(shù)據(jù)結(jié)構(gòu)與算法教程》、《Python函數(shù)使用技巧總結(jié)》、《Python入門與進階經(jīng)典教程》及《Python文件與目錄操作技巧匯總》
希望本文所述對大家Python程序設(shè)計有所幫助。
相關(guān)文章
pyecharts實現(xiàn)數(shù)據(jù)可視化
這篇文章主要介紹了pyecharts實現(xiàn)數(shù)據(jù)可視化,pyecharts 是百度開源的,適用于數(shù)據(jù)可視化的工具,配置靈活,展示圖表相對美觀,順滑,下面更多詳細內(nèi)容,需要的小伙伴可以參考一下2022-03-03基于opencv的selenium滑動驗證碼的實現(xiàn)
這篇文章主要介紹了基于opencv的selenium滑動驗證碼的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2020-07-07