我有5个地块的5个不同地块。我想指出特定时间点在统计上的显着差异。我使用annotate()在时间点上方的各个图中放置星号。但是,当我将所有地块组合成一个图形时,星号会从地块上移开。 y比例尺未固定似乎是一个问题。我正在提供尽可能多的数据。代码的第一位用于其中一个组。这五个组的图看起来都相对相似。第二位是我用来组合绘图的数据框。一张图单独附上的图片,然后所有图组合在一起。在多个图上应该有多个星号
ggplot(data,aes(X,Y,group=Group,color=Group))+
theme_bw()+
theme(panel.grid.major=element_line(color="white",size=.1))+
theme(panel.grid.minor=element_line(color="white",size=.1))+
geom_point(stat="summary")+
geom_errorbar(stat="summary",fun.data=mean_se,width=0.25)+
geom_line(stat="summary")+
scale_color_manual(labels = c("C", "T"),values=c("black", "red"))+
theme(axis.title.y = element_text(vjust=2.5))+
annotate("text", x=5, y=3, label= "*",size=10)
grid.newpage()
grid.draw(rbind(ggplotGrob(plotanimal1),
ggplotGrob(plotanimal2),
ggplotGrob(plotanimal3),
ggplotGrob(plotanimal4),
ggplotGrob(plotanimal5)))
您可以通过将geom_point
与shape = 42
结合使用来制作星号。这样,ggplot将自动固定y轴值本身。您需要将美学设置为与annotate
相同的值。所以代替
annotate("text", x=5, y=3, label= "*",size=10)
您可以做
geom_point(aes(x=5, y=3), shape = 42, size = 2)
您是否尝试过使用软件包patchwork
来组织绘图?它通常比grid.draw更好]