我正在使用R中的ggplot绘制多个条件,并使用facet_wrap进行分面展示。
我想将带有绘图名称的条纹放在垂直轴上的右侧,而不是在顶部。
以下是一个例子:
library(ggplot2)
dat<- data.frame(name= rep(LETTERS[1:5], each= 4), value= rnorm(20), time= rep(1:5, 4))
gg<- ggplot(data= dat, aes(x= time, y= value)) +
geom_point() +
facet_wrap(~ name, ncol= 1)
这里的图表名称(A、B、C、D、E)在顶部,我希望它们像这里一样在右边:
gg + facet_grid(name ~ .)
是否有一个简单的开关可以实现这个功能?(我不使用 facet_grid
,因为我想使用 facet_wrap
中提供的选项 nrow
和 ncol
)。
谢谢!Dario
sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-apple-darwin10.8.0 (64-bit)
locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggplot2_0.9.3.1
loaded via a namespace (and not attached):
[1] colorspace_1.2-4 dichromat_2.0-0 digest_0.6.4 grid_3.0.1
[5] gtable_0.1.2 labeling_0.2 MASS_7.3-29 munsell_0.4.2
[9] plyr_1.8.1 proto_0.3-10 RColorBrewer_1.0-5 Rcpp_0.11.0
[13] reshape2_1.2.2 scales_0.2.3 stringr_0.6.2 tools_3.0.1
facet_grid
一起使用。你总是可以尝试使用grid/gridExtra
进行低级别的操作,但那是一条复杂的路径。 - tonytonov