R/ggplot : Vertical strip text with facet_wrap

标签 r ggplot2 facet-wrap

我在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,因为我想使用nrow附带的ncolfacet_wrap选项)。

谢谢!达里奥
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       

最佳答案

为了将来引用,您现在可以使用strip.position="right"put them on the right side,例如:

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, strip.position="right")

关于R/ggplot : Vertical strip text with facet_wrap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28479473/

相关文章:

r - 编辑面/条与图之间的距离

r - 循环中直方图的facet_wrap : "At least one layer must contain all variables"

ggplot2 - 使用第二个变量标记 ggplot2 构面中的轴刻度

R:在极坐标中绘制半径 = 1 和角度 0-2pi 的圆?

r - 侧边栏菜单项之间的空间

r - ggplot 散点图和线条

r - 突出显示跨地 block 具有恒定抖动的一些点(ggplot2)

R - 图中线交点的坐标

r - 如何使用 R 中的 Web 抓取从 Power BI 仪表板获取表格

r - 如何绘制具有显着水平的箱线图?