# 构造数据labels = L1 L2 L3 L4 L5data_a = 20 34 30 35 27data_b = 25 32 34 20 25data_c = 12 20 24 17 16x = nparangelenlabelswidth = 25pltrcParamsfontfamily = Times New Roman# plotsfig ax = pltsubplotsfigsi
构造数据
labels = ['L1', 'L2', 'L3'] data_a = [20, 34, 30] data_b = [25, 32, 34] data_c = [12, 20, 24]
x = np.arange(len(labels)) width = .25
plt.rcParams['font.family'] = "Times New Roman"
plots
fig, ax = plt.subplots(figsize=(5, 3), dpi=200) bar_a = ax.bar(x - width / 2, data_a, width, label='MSE', color='#130074', ec='black', lw=.5) bar_b = ax.bar(x + width / 2, data_b, width, label='MAE', color='#CB181B', ec='black', lw=.5) bar_c = ax.bar(x + width * 3 / 2, data_c, width, label='RMSE', color='white', ec='black', lw=.5)
定制化设计
ax.tick_params(axis='x', direction='in', bottom=False) ax.tick_params(axis='y', direction='out', labelsize=8, length=3) ax.set_xticks(x) ax.set_xticklabels(labels, size=10) ax.set_ylim(bottom=0, top=40) ax.set_yticks(np.arange(0, 50, step=5))
for spine in ['top', 'right']: ax.spines[spine].set_color('none')
ax.legend(fontsize=7, frameon=False)
text_font = {'size': '14', 'weight': 'bold', 'color': 'black'} ax.text(.03, .93, "(a)", transform=ax.transAxes, fontdict=text_font, zorder=4) plt.savefig('Column1.png', width=5, height=3,dpi=900, bbox_inches='tight') plt.show()
原文地址: https://www.cveoy.top/t/topic/OoU 著作权归作者所有。请勿转载和采集!