在ggplot 2中在各个方面注释我想用以下代码对情节的最后一个方面进行注释:library(ggplot2)p <- ggplot(mtcars, aes(mpg, wt)) + geom_point()p <- p + facet_grid(. ~ cyl)p <- p + annotate("text", label = "Test", size = 4, x = 15, y = 5)print(p)但这段代码在每个方面都对文本进行了注释。如果你能指导我如何只从一个方面得到注释的文本,我将不胜感激。提前谢谢。
3 回答
HUX布斯
TA贡献1876条经验 获得超6个赞
ann_text <- data.frame(mpg = 15,wt = 5,lab = "Text", cyl = factor(8,levels = c("4","6","8")))p + geom_text(data = ann_text,label = "Text")
开心每一天1111
TA贡献1836条经验 获得超13个赞
ann_text <- data.frame(mpg = 15,wt = 5, cyl = factor(8,levels = c("4","6","8")))p + geom_text(data = ann_text,label = "Text" )
ann_text <- data.frame(mpg = c(14,15),wt = c(4,5),lab=c("text1","text2"), cyl = factor(c(6,8),levels = c("4","6","8")))p + geom_text(data = ann_text,aes(label =lab) )
- 3 回答
- 0 关注
- 716 浏览
添加回答
举报
0/150
提交
取消