x = [1,2,3,4,5]
y = [1,2,3,4,5]
fig = plt.figure()
axes = fig.subplots()
axes.plot(x,y, label="test")
legend = plt.legend()
fig.canvas.draw()
print(f'Height: {legend.get_window_extent().height/100} in')
print(f'Width: {legend.get_window_extent().width/100} in')
Output:
Height: 0.18 in
Width: 0.55125 in