【发布时间】:2018-01-28 13:38:09
【问题描述】:
我想给我的图表添加标签,这样我就不需要使用图例了,但我不知道该怎么做。
例如,使用这些数据我得到这 3 行
x = c(1:10)
y = x^2
z = x^3
w = 2*x + 7
plot(x,y,type="l", col="red")
lines(z, type="l", col="blue")
lines(w, type="l", col="green")
https://gyazo.com/a674a148c57e38160a502f3f51a41046
我想分别标记每个图形 y、z 和 w。我希望它看起来像这样
https://gyazo.com/93a9e055a02f42fb61c3e1e438485dee
每个图表都有一个标签,因此不需要图例
我看了这个帖子 How can i label points in this scatterplot?
但这是一个散点图,我不知道如何为连续图做。
【问题讨论】:
-
如果你使用ggplot2或lattice graphics,directlabels包可以自动定位它们。