我有一个小数据集,我正在绘制一些对图。我有足够的数据点,我想为每个点添加文本标签。有没有办法做到这一点?我已经看过一些颜色编码的例子,但我更喜欢在我的数据帧中有一个列的文本标签。对于下面的例子,我想绘制rr,position.cm和degra,并用风暴标记点。谢谢!
example <- structure(list(storm = structure(c(1L, 10L, 12L, 13L, 15L, 16L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L), .Label = c("1", "2", "3", "4",
"5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15",
"16"), class = "factor"), position.cm = c(-50.1260416666667,
-11.5458333333333, -11.4005208333333, -13.303125, -8.91302083333333,
-8.9984375, -20.0125, -18.7666666666667, -30.4583333333333, -52.8177083333333,
-56.9135416666667, -18.5229166666667, -19.94375, -11.5765625),
precip = c(27.7, 11, 17.8, 60, 48.6, 62.6, 48.5, 38.4, 40.6,
16.6, 45.2, 21.8, 39.8, 68.4), rr = c(6.2182629900722, 19.5252223545455,
6.50223807303371, 94.2317387291667, 85.9112139917695, 110.894968051118,
56.2344034298969, 29.559527546224, 1.74602332820197, 0, 11.3076659103982,
28.3121063302752, 50.5574166212312, 63.6394516524123)), .Names = c("storm",
"position.cm", "precip", "rr"), class = "data.frame", row.names = c(107L,
108L, 110L, 111L, 113L, 114L, 115L, 116L, 117L, 118L, 119L, 120L,
121L, 122L))
pairs(example[, c("position.cm", "rr", "precip")])
答案 0 :(得分:3)
此listserv chain使用&#39;对()&#39;
讨论标注点这是他们提供的代码示例:
pairs(matrix(rnorm(15), ncol=3), pch=21, bg="grey", cex=4,
panel=function(x, y, ...) { points(x, y, ...);
text(x, y, letters[1:5]) })
对于你的例子:
pairs(example[, c("position.cm", "rr", "precip")], pch=21, bg="grey", cex=4,
panel=function(x, y, ...) { points(x, y, ...);
text(x, y, example[,"storm"]) })
答案 1 :(得分:1)