注意:这篇文章上次更新于1336天前,文章内容可能已经过时。
代码
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.pyplot import MultipleLocator
plt.rcParams['axes.unicode_minus']=False #显示负数
# plt.rcParams["font.sans-serif"]=["SimHei"] # 显示中文
plt.figure(figsize=(9,6))
scores=(np.array([85,86,78,65,66,74,64,77,75,72,80,73,68,71,79])-5,
np.array([86,58,68,78,79,74,62,66,60,72,73,77,61,78,84])-15,
np.array([79,55,54,60,79,77,65,63,64,77,56,52,78,73,55])-15,
np.array([92,86,73,75,84,70,69,72,77,70,78,76,68,88,83])-5,
np.array([86,53,64,80,73,68,63,54,67,69,63,61,59,60,77])-15,
np.array([75,49,65,73,65,61,62,64,53,58,56,54,72,69,74])-25,
np.array([72,45,68,63,58,53,56,57,60,49,50,57,56,52,67])-30,
np.array([90,85,75,87,70,86,82,83,79,86,73,85,89,83,72]))
labels = ['Red channel','GDCP','UIBLA','Fusion-based','FUnIE-GAN','UGAN','UWCNN','Ours']
plt.box(on=True)
# plt.grid(b=None, which='major', axis='both') # 网格线
plt.boxplot(scores,labels=labels,notch=True, meanline=True, showmeans=True)
plt.ylabel("Preference Scores",fontproperties = 'Times New Roman',fontsize=16)
plt.xticks(fontproperties = 'Times New Roman')
plt.yticks(fontproperties = 'Times New Roman')
## 修改 y 轴刻度间隔
ax=plt.gca()
y_major_locator=MultipleLocator(10)
ax.yaxis.set_major_locator(y_major_locator)
plt.ylim(-5,100) # y 轴范围
# plt.title("主观评分")
plt.savefig(r".//scores.png") # 保存成 png
plt.savefig('scores.pdf') # 保存成 pdf
plt.show() # 显示
更多参考
[1] 设置新罗马字体
[2] 官方文档