这是我的例子,从
这个问题
:
ex<-data.frame(a=factor(letters[1:10]),
b=系数(rep(c(‘b’,‘a’),5)),
C=代表(字母[1:5],2))
例如$A<-系数(例如$A,级别=Ex$A[订单(例如$B)])
当格普洛丁…
库(ggplot2)
ggplot(数据=ex,aes(y=a,x=c))。+
几何点()。+
注释(xmin='b',xmax='d',ymin=-inf,ymax=inf,geom='rect',alpha=0.2)
……我们得到这个情节:

但是,灰色矩形如何从之间开始?aandband end betweend**ande?:
ex <- data.frame(a = factor(letters[1:10]),
b = factor(rep(c('b', 'a'), 5)),
c = rep(letters[1:5], 2))
ex$a <- factor(ex$a, levels = ex$a[order(ex$b)])
当G绘图时…
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)
…我们得到这个情节:

然而,灰色矩形如何从中间开始a和b结束于d**和e?