如何在matplotlib中绘制内嵌线标签? [英] How can I draw inline line labels in matplotlib?

查看:493
本文介绍了如何在matplotlib中绘制内嵌线标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下面的图形,由几行组成:

I have the following graph, consisting of several lines:

现在,我想标记图中的所有线条.但是,使用legend()将所有标签夹在一个框中,这使得该图有些难以解释.我想使用的是内联标签.我理想的输出将使用以下matplotlib等高线图之类的标签,但使用文本标签代替线条:

Now, I would like to label all the lines in the plot. However, using legend() crams all the labels together in a box, which makes the plot somewhat difficult to interpret. What I'd like to to instead is to use inline labels. My ideal output would use labels like the following matplotlib contour plot, but with text labels for lines instead of numbers:

我无法在matplotlib文档中找到如何执行此操作的方法.有没有办法做到这一点?如果没有,我可以使用什么其他软件来生成这种图?

I haven't been able to find out how to do this in the matplotlib documentation. Is there a way to achieve this? If not, what other software could I use to generate this type of plot?

推荐答案

我可以为您的问题建议另一种解决方案.由于在您的案例中,图例与图表重叠,因此您可能只想将图例移出绘图.

May I suggest another solution to your problem. Since in your case legend overlaps the charts you might just want to move the legend outside of the plot.

将图例移出情节的方法在此处进行了描述: 将matplotlib图例移到外部的轴使其被图形框切断

Method do move legend outside of plot is described here: Moving matplotlib legend outside of the axis makes it cutoff by the figure box

这篇关于如何在matplotlib中绘制内嵌线标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆