【发布时间】:2020-06-04 20:47:53
【问题描述】:
我想创建一条横穿两个地块的水平线,并结合拼凑包。
library(ggplot2)
library(patchwork)
# Annotation after plot
p1 <- ggplot(mtcars, aes(x=disp,y=mpg))+
geom_point()
p2 <- ggplot(mtcars, aes(x=hp,y=mpg))+
geom_point()
# Want line across plots at y (mpg) of 15
p3 <- (p1+p2)+annotate("segment",x=-Inf,xend=Inf,y=15,yend=15)
p3
尝试在每个绘图中添加注释。
# Annotation with each plot
p1 <- ggplot(mtcars, aes(x=disp,y=mpg))+
geom_point()+
annotate("segment",x=-Inf,xend=Inf,y=15,yend=15)
p2 <- ggplot(mtcars, aes(x=hp,y=mpg))+
geom_point()+
annotate("segment",x=-Inf,xend=Inf,y=15,yend=15)
p1+p2
【问题讨论】:
标签: r ggplot2 annotate patchwork