1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| import matplotlib.pyplot as plt import numpy as np
plt.rcParams['font.family'] = 'Times New Roman' plt.rcParams['font.family'] = ['SimSun'] plt.rcParams['font.sans-serif'] = ['SimHei'] plt.rcParams['axes.unicode_minus'] = False
models = ['FR', 'YOLOX', '文献1', '文献2', 'Yolov8-3']
r2_scores = [ 0.89, 0.91, 0.87, 0.88, 0.93
]
colors = ['r', 'Orange', "Brown", "Teal", "BLACK"]
fig, ax1 = plt.subplots(figsize=(4, 4))
bar_width = 0.58
bars_r2 = ax1.bar(models, r2_scores, color=colors, width=bar_width) ax1.set_ylabel('P/%', fontsize=12)
for bar in bars_r2: yval = bar.get_height() ax1.text(bar.get_x() + bar.get_width()/2, yval, round(yval, 3), ha='center', va='bottom', fontsize=12)
ax1.spines['top'].set_visible(False) ax1.spines['right'].set_visible(False) ax1.spines['left'].set_visible(True) ax1.spines['bottom'].set_visible(True)
plt.subplots_adjust(left=0.145, right=0.98, bottom=0.06, top=0.98, wspace=0.4, hspace=0.8)
plt.xticks(fontsize=12) plt.yticks(fontsize=12)
plt.savefig('P.png', dpi=400)
|