如何在不切换公式的情况下更改facet_grid()
标签的位置?
library(plyr)
library(ggplot2)
data = data.frame(id = 1:10, value = rnorm(100*10))
data = ddply(data, .(id), transform, obs = 1:100)
ggplot(data = data, aes(x = obs, y = value, color = factor(id))) +
geom_line() +
facet_grid(id ~.)
在下图中,我希望面板文本从面板的右侧切换到顶层。
答案 0 :(得分:5)
ggplot(data = data, aes(x = obs, y = value, color = factor(id))) +
geom_line() +
facet_wrap( ~id, ncol=1)