在图中标注线 [英] Label lines in a plot
本文介绍了在图中标注线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用绘制两行
plot(x, y, type = "l", color = "red")
和
points(x2, y2, type = "l", color = "blue")
我希望能够在每行旁边添加一个标签(而不是图例). 我很确定可以在 http://directlabels.r-forge中使用该程序包. r-project.org/.
I want to be able to add a label next to each line (instead of a legend). I am pretty sure it is possible using the package in http://directlabels.r-forge.r-project.org/.
但是,我没有找到一种简单的方法.
Yet, I don't find an easy way of doing that.
推荐答案
您可以通过point& click方法在text()
中使用locator()
.
You can use the locator()
within text()
by point&click method.
y <- rnorm(100, 10)
y2 <- rnorm(100, 20)
x <- 1:100
plot(x, y, type = "n", ylim = c(0, 40), xlim = c(0, 120))
lines(x, y)
lines(x, y2, col = "red")
text(locator(), labels = c("red line", "black line)"))
这篇关于在图中标注线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文