我想用以下代码在图的最后一个面上注释一些文本:
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)
Run Code Online (Sandbox Code Playgroud)

但是这段代码注释了每个方面的文本.如果您指导我如何仅在一个方面获得带注释的文本,我将非常感激.提前致谢.
可能重复:
在ggplot2中对单个构面上的文本进行注释
我正在研究一个有3种物种的数据集.它们是苹果,橙子和香蕉.
我想仅在底部面板上注释facet.但是,默认情况下,我会在所有图上获得注释.我只能在所需的情节上获得文本注释.但是,我很困惑我需要为箭头/段做什么.
这是我的代码:
library(ggplot2)
library(grid)
tempobs <- read.csv("temp data share.csv",header=T, sep=",")
p1 <- ggplot(tempobs,aes(x=time,y=data))+geom_point(data=tempobs,aes(x=time,y=data,colour=group1))+facet_wrap(~id,ncol=1)+theme_bw()
p1 <- p1 + xlab("Julian Day (2008-2009)")+ylab(expression(Temperature~(degree*C)))+ element_blank()+ theme(
legend.position="right",
legend.direction="vertical",
legend.title = element_blank()) +coord_cartesian(xlim=c(250,550))+coord_cartesian(ylim=c(0,40))+scale_x_continuous(breaks=c(250,300,350,400,450,500,550),labels=c("250","300","350","34","84","134","184"))
p1
### This is how it should look like (though shows annotations for all the plots)
p + annotate("text",x=340,y=3,label="2008",size=3)+annotate("segment",x=366,xend=366,y=0,yend=2,size=0.5)+annotate("text",x=390,y=3,label="2009",size=3)+annotate("segment",x=366,xend=310,y=1,yend=1,size=0.5,arrow=arrow(length=unit(0.2,"cm")))+annotate("segment",x=366,xend=420,y=1,yend=1,size=0.5,arrow=arrow(length=unit(0.2,"cm")))
### This is what I did to show text annotation on the bottom panel
ann_text <- data.frame(x=c(340,390),y=c(3,3),id=c("orange"),label=c("2008","2009"))
p1 <- p1 + geom_text(data=ann_text,aes(x=x,y=y,label=label,size=3),show_guide=F)
p1
Run Code Online (Sandbox Code Playgroud)
现在,我想根据整体图表添加箭头和细分.
我的数据可以在https://www.dropbox.com/s/dfcmqrslskwdh80/temp%20data%20share.csv上找到
我的输出是
这是我只用文本注释得到的.但对于段注释我总是有错误.您可以注意到底部面板上添加的文本标签2008和2009.

输出显示我想要的注释,但它在所有方面.我只希望在底部. …