切换facet_grid标签的位置

时间:2014-03-02 11:44:45

标签: r ggplot2 facet-wrap

如何在不切换公式的情况下更改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 ~.)

在下图中,我希望面板文本从面板的右侧切换到顶层。

enter image description here

1 个答案:

答案 0 :(得分:5)

ggplot(data = data, aes(x = obs, y = value, color = factor(id))) + 
         geom_line() +
         facet_wrap( ~id, ncol=1)

enter image description here