R 注释矩形以在两个因子之间开始
这是我的例子,来自: 。。。我们得到这个图:R 注释矩形以在两个因子之间开始,r,ggplot2,R,Ggplot2,这是我的例子,来自: 。。。我们得到这个图: 但是,灰色矩形如何在a和b之间开始,在d和e之间结束 当a是1和b是2时,您需要设置的是xmid=1.5(即a和b),然后对d和e执行相同的操作 ggplot(ex, aes(c, a)) + geom_point() + annotate(xmin = 1.5, xmax = 4.5, ymin = -Inf, ymax = Inf, geom = "rect", alpha
但是,灰色矩形如何在a和b之间开始,在d和e之间结束 当
a
是1
和b
是2
时,您需要设置的是xmid=1.5
(即a
和b
),然后对d
和e
执行相同的操作
ggplot(ex, aes(c, a)) +
geom_point() +
annotate(xmin = 1.5, xmax = 4.5,
ymin = -Inf, ymax = Inf,
geom = "rect", alpha = 0.2)
library(ggplot2)
ggplot(data = ex, aes(y = a, x = c)) +
geom_point() +
annotate(xmin = 'b', xmax = 'd', ymin = -Inf, ymax = Inf, geom = 'rect', alpha = 0.2)
ggplot(ex, aes(c, a)) +
geom_point() +
annotate(xmin = 1.5, xmax = 4.5,
ymin = -Inf, ymax = Inf,
geom = "rect", alpha = 0.2)