Legend.set_bbox_to_anchor()
,但我的尝试似乎根本没有移动图例。这是我最近的尝试:
leg.set_bbox_to_anchor((1,1), transform = ax.transAxes)
其中
leg
是 Legend 对象,
ax
是父 Axes 对象。您有什么想法我该如何实现这一目标吗?
plt.legend(bbox_to_anchor=(1, 1), loc=1, borderaxespad=0)
。
# Get legend
leg = ax.legend(loc='lower left')
# Reposition it using axes relative coordinates (0...1, 0...1)
leg.set_bbox_to_anchor((0.250, 0.11, 0.3, 0.5), transform=ax.transAxes)