图例格式 - 制作粗体边框,或更大/不同的字体

Legend format - make bold border, or bigger / different font

有没有人有简单的方法来更改图例的大小以使其变大或使边框变粗?

group_a = (a,b,c,d,e)
group_b = (f,g,h,i,j)
group_c = (k,l,m,n,o)

width = 0.2

x = np.arange(5)

plt.bar(x-0.2, group_a, width, color = 'cyan')
plt.bar(x, group_b, width, color = 'orange')
plt.bar(x+0.2, group_c, width, color = 'green')

plt.xticks(x, ['1','2','3','4','5'])
plt.xlabel("quarter")

plt.ylabel('%')

plt.legend(['Group A','Group B','Group C'])


print(f'Group A: {a},{b},{c},{d},{e}')
print(f'Group B: {f},{g},{h},{i},{j}')
print(f'Group C: {k},{l},{m},{n},{o}')

plt.show()

您可以为 plt.legend() 使用 loc 关键字:

plt.legend(['Group A','Group B','Group C'], loc=(1.04, 1))

输出: