How can I draw inline line labels in matplotlib?

廉价感情. 提交于 2019-12-03 16:41:06

问题


I have the following graph, consisting of several lines:

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:

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?


回答1:


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.

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



来源:https://stackoverflow.com/questions/21551810/how-can-i-draw-inline-line-labels-in-matplotlib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!