gpt4 book ai didi

python - matplotlib 由线条和图片组成的图例标签在将图例移出图形时丢失线条

转载 作者:太空宇宙 更新时间:2023-11-03 21:38:07 27 4
gpt4 key购买 nike

我想从图片和线条中重现此标签(请参阅: Replace Matplotlib legend's labels with image ),但是当我尝试使用 bbox_to_anchor 将其移出轴时,标签中的线条消失,而图片仍然存在。没有什么会被切断。以下是相关代码部分。由于我有不止一行,因此我使用行列表和图例列表(后者为空)。

plt.legend(handles = lineliste, labels = legendliste, handler_map = 
handler_map, handlelength=4, labelspacing=0.0, fontsize=36, borderpad=0.1,
handletextpad=0.2, borderaxespad=0.1, handleheight=2, loc="upper center",
frameon = False, bbox_to_anchor=(2.02,1))

@ImportanceOfBeingErnest,正如您提供第一个问题的答案一样,您有解决方案吗?

最佳答案

抱歉,在 original solution有一个

l.set_clip_on(False) 

失踪了。我编辑了那个答案。现在看起来像

enter image description here

bbox_to_anchor=(1.1,1) 添加到图例调用时。

关于python - matplotlib 由线条和图片组成的图例标签在将图例移出图形时丢失线条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53110330/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com