在下面的示例中,我希望将geom_rug
设置在x轴下方(图的外部):
set.seed(1)
Time = seq( as.Date('2010-10-01'),as.Date('2010-11-01'),'2 day' )
Var1 = sample (length(Time))
Var2 = sample (length(Time))
tibble(Time, Var1, Var2) %>%
tidyr::gather(variable, value, -Time) %>%
ggplot(aes(x = Time, y = value)) +
geom_point() +
geom_rug(sides = 'b') +
theme_bw() +
facet_grid(variable ~ ., scales = 'free')
答案 0 :(得分:2)
这已成为ggplot2 3.2.0的最新版本的功能 如本页https://ggplot2.tidyverse.org/reference/geom_rug.html所示, 这是使用以下方法完成的:
# increase the line length and
# expand axis to avoid overplotting
p + geom_rug(length = unit(0.05, "npc")) +
scale_y_continuous(expand = c(0.1, 0.1))