欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Python畫柱狀統(tǒng)計圖操作示例【基于matplotlib庫】

 更新時間:2018年07月04日 10:17:52   作者:閱微草堂123  
這篇文章主要介紹了Python畫柱狀統(tǒng)計圖操作,結(jié)合實(shí)例形式分析了Python基于matplotlib庫實(shí)現(xiàn)圖形繪制的相關(guān)操作技巧,需要的朋友可以參考下

本文實(shí)例講述了Python畫柱狀統(tǒng)計圖操作。分享給大家供大家參考,具體如下:

一、工具:python的matplotlib.pyplot

二、案例:

import matplotlib.pyplot as plt
import numpy as np
#添加圖形屬性
plt.xlabel('Age range')
plt.ylabel('Number')
plt.title('The statistics of face age dataset')
a = plt.subplot(1, 1, 1)
plt.ylim=(10, 40000)
x = [10, 20, 30, 40, 50, 60, 70]
x1 = [7, 17, 27, 37, 47, 57, 67]
x2 = [13, 23, 33, 43, 53, 63, 73]
Y1 = [41, 39, 13, 69, 39, 14, 7]
Y2 = [0, 15, 20, 105, 79, 37, 43]
Y3 = [0, 91, 404, 464, 521, 375, 553]
#這里需要注意在畫圖的時候加上label在配合plt.legend()函數(shù)就能直接得到圖例,簡單又方便!
plt.bar(x1, Y1, facecolor='red', width=3, label = 'FG-NET')
plt.bar(x, Y2, facecolor='green', width=3, label = 'MORPH')
plt.bar(x2, Y3, facecolor='blue', width=3, label = 'CACD2000')
plt.legend()
plt.show()

效果圖如下:

更多關(guān)于Python相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Python數(shù)學(xué)運(yùn)算技巧總結(jié)》、《Python數(shù)據(jù)結(jié)構(gòu)與算法教程》、《Python函數(shù)使用技巧總結(jié)》、《Python字符串操作技巧匯總》、《Python入門與進(jìn)階經(jīng)典教程》及《Python文件與目錄操作技巧匯總

希望本文所述對大家Python程序設(shè)計有所幫助。

相關(guān)文章

最新評論