这是我的示例,来自this question:
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)])
ggploting时...
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
之间并在 {{1 }} **和 d
?