新聞中心
python直方圖顯示值的方法:

為企業(yè)提供成都做網(wǎng)站、成都網(wǎng)站設(shè)計、網(wǎng)站優(yōu)化、營銷型網(wǎng)站、競價托管、品牌運營等營銷獲客服務(wù)。成都創(chuàng)新互聯(lián)擁有網(wǎng)絡(luò)營銷運營團隊,以豐富的互聯(lián)網(wǎng)營銷經(jīng)驗助力企業(yè)精準獲客,真正落地解決中小企業(yè)營銷獲客難題,做到“讓獲客更簡單”。自創(chuàng)立至今,成功用技術(shù)實力解決了企業(yè)“網(wǎng)站建設(shè)、網(wǎng)絡(luò)品牌塑造、網(wǎng)絡(luò)營銷”三大難題,同時降低了營銷成本,提高了有效客戶轉(zhuǎn)化率,獲得了眾多企業(yè)客戶的高度認可!
可以使用text()函數(shù)通過為直方圖添加注釋的方法來顯示值。
函數(shù)功能:添加圖形內(nèi)容細節(jié)的無指向型注釋文本
函數(shù)語法:
plt.text(x, y, string, weight="bold", color="b")
參數(shù)說明:
-
x: 注釋文本內(nèi)容所在位置的橫坐標
-
y:注釋文本內(nèi)容所在位置的縱坐標
-
string:注釋文本內(nèi)容
-
weight:注釋文本內(nèi)容的粗細風(fēng)格
-
color:注釋文本內(nèi)容的字體顏色
# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
#num_list = [1.5,0.6,7.8,6]
fig, ax = plt.subplots()
num_list = [7870,81937,17529598,6225227]
name_list = ['Eviction','Failed','Finished','Killed']
b = ax.bar(name_list, num_list)
plt.bar(range(len(num_list)), num_list,color='rbg',tick_label=name_list)
for a, b in zip(name_list, num_list):
ax.text(a, b+1, b, ha='center', va='bottom')
plt.title('Numbers of Four eventtypes')
plt.xlabel('Eventtype')
plt.ylabel('Number')
plt.show()
效果如下:
分享名稱:創(chuàng)新互聯(lián)Python教程:python直方圖如何顯示值?
文章網(wǎng)址:http://www.fisionsoft.com.cn/article/dhghscg.html


咨詢
建站咨詢
