我试图在matplotlib中的情节之外放置一个相当广泛的传说。传说中有很多条目,每个条目都可能很长(但我不知道具体多长)。在
显然,这很容易使用
legendHandle = plt.legend(loc = "center left", bbox_to_anchor = (1, 0.5))
但问题是这个传说被窗户的边缘切断了。我花了很长时间寻找解决办法。到目前为止,我能找到的最好的东西是:
^{pr2}$不幸的是,这并不能真正解决我的问题。由于将显式系数0.8应用于方框宽度,因此这仅适用于图形和图例宽度的一个特定组合。如果我调整“体形”窗口的大小,或者图例项的长度不同,则无法正常工作。在
我只是不明白把一个传奇人物放在人物之外是多么困难。我习惯了Matlab,它很简单
legend('Location', 'eastoutside')
在Python中有没有我遗漏的东西?在
刚才无意中发现了这个问题,我想你可以用这个数字的图例方法:
虽然图例位于轴外部,但如果图例太大,它可能仍与轴重叠。在
图例的放置可以通过使用参数来控制 loc和bbox_-to-uAnchor。 下面是一个代码示例:
现在您应该看到下图: figure with legend outside
经过多次尝试,这是我能想到的最好的:
在我迄今为止测试过的案例中,这个传说或多或少是好的。用法是
^{pr2}$让我问一个问题,我已经在一个评论。。。对于matplotlib开发人员,我该如何建议将其作为一个附加特性呢?(不是我的黑客,而是一种在人物之外拥有传奇的本土方式)
相关问题 更多 >
编程相关推荐