python柱状图分析代码
生活随笔
收集整理的這篇文章主要介紹了
python柱状图分析代码
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
%matplotlib notebookimport matplotlib.pyplot as plt
import numpy as npplt.rcParams['font.sans-serif']=['SimHei']
plt.rcParams['axes.unicode_minus'] = False# 構(gòu)建數(shù)據(jù)
x_data = ['100', '200', '300', '400', '500', '600', '700','800','900','1000','2000','3000','4000']
y_data = [0, 92.26, 93.53, 95.00, 94.86, 88.25, 93.53,93.81,95.85,91.41,86.84,86.91,87.54]
y_data2 = [0, 72.54, 84.08, 80.20, 83.65, 84.96, 82.94,85.71,86.15,83.08,82.57,83.25,74.66]
# 繪圖
plt.bar(x=x_data, height=y_data, width=0.8,label='預(yù)處理后', color='steelblue', alpha=0.8)
plt.bar(x=x_data, height=y_data2, width=0.8,label='預(yù)處理前', color='indianred', alpha=0.8)
# 在柱狀圖上顯示具體數(shù)值, ha參數(shù)控制水平對(duì)齊方式, va控制垂直對(duì)齊方式
for x, y in enumerate(y_data):plt.text(x, y + 1, '%s%%' % y, ha='center', va='bottom')
for x, y in enumerate(y_data2):plt.text(x, y + 3, '%s%%' % y, ha='center', va='top')
# 設(shè)置標(biāo)題
plt.title("預(yù)處理前后Recall對(duì)比")
# 為兩條坐標(biāo)軸設(shè)置名稱
plt.xlabel("訓(xùn)練次數(shù)")
plt.ylabel("Reall")
# 顯示圖例
plt.legend(loc=4)
plt.show()
%matplotlib notebookimport matplotlib.pyplot as plt
import numpy as npplt.rcParams['font.sans-serif']=['SimHei']
plt.rcParams['axes.unicode_minus'] = False# 構(gòu)建數(shù)據(jù)
x_data = ['100', '200', '300', '400', '500', '600', '700','800','900','1000','2000','3000','4000']
y_data = [0, 67.80, 68.94, 69.32, 70.30, 65.60, 68.37,70.00,71.17,68.75,64.65,63.18,64.67]
y_data2 = [0, 54.50, 61.78, 60.87, 61.15, 62.36, 62.19,63.28,63.81,62.28,62.20,63.07,57.24]
# 繪圖
plt.bar(x=x_data, height=y_data, label='預(yù)處理后', color='steelblue', alpha=0.8)
plt.bar(x=x_data, height=y_data2, label='預(yù)處理前', color='indianred', alpha=0.8)
# 在柱狀圖上顯示具體數(shù)值, ha參數(shù)控制水平對(duì)齊方式, va控制垂直對(duì)齊方式
for x, y in enumerate(y_data):plt.text(x, y + 1, '%s%%' % y, ha='center', va='bottom')
for x, y in enumerate(y_data2):plt.text(x, y + 3, '%s%%' % y, ha='center', va='top')
# 設(shè)置標(biāo)題
plt.title("預(yù)處理前后IOU對(duì)比")
# 為兩條坐標(biāo)軸設(shè)置名稱
plt.xlabel("訓(xùn)練次數(shù)")
plt.ylabel("IOU")
# 顯示圖例
plt.legend(loc=4)
plt.show()
參考文章: https://www.csdn.net/gather_23/MtjaAg5sNDUxLWJsb2cO0O0O.html
https://www.csdn.net/gather_23/MtjaAg5sNDUxLWJsb2cO0O0O.html
總結(jié)
以上是生活随笔為你收集整理的python柱状图分析代码的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: CMD 控制台CMD程序怎么执行完不关闭
- 下一篇: python 用matplotlib.p