Dav*_*ave 69
2016年搜索的答案.
随着ggplot22.0的开关参数会做到这一点的facet_grid还是facet_wrap:
默认情况下,标签显示在图表的顶部和右侧.如果为"x",则顶部标签将显示在底部.如果为"y",则右侧标签将显示在左侧.也可以设置为"both".
ggplot(...) + ... + facet_grid(facets, switch="both")
Run Code Online (Sandbox Code Playgroud)
截至ggplot2 2.2.0,
现在可以
facet_wrap()使用strip.position参数(弃用switch)自由定位条带.
当前文档,仍处于2.1,但strip.position被记录在开发文档.
默认情况下,标签显示在图表的顶部.使用strip.position,可以通过设置将标签放在四边中的任何一边
strip.position = c("top", "bottom", "left", "right")
ggplot(...) + ... + facet_wrap(facets, strip.position="right")
Run Code Online (Sandbox Code Playgroud)
小智 15
您现在可以使用facet_wrap(~var, strip.position = "bottom"),但由于某种原因,这会导致标签位于轴刻度标记标签上方,而不是下方(我认为这更有意义),正如您从我的一小部分图表的屏幕截图中看到的

如果你想要下面的标签,你必须这样做
ggplot(zzz, aes(x = c1, y = c2)) +
facet_wrap(~ gp, scales = "free", nrow = 3, strip.position = "bottom") +
geom_point() +
theme(
aspect.ratio = 1,
strip.background = element_blank(),
strip.placement = "outside"
)
Run Code Online (Sandbox Code Playgroud)
如下所示:https : //github.com/tidyverse/ggplot2/issues/2622
| 归档时间: |
|
| 查看次数: |
30471 次 |
| 最近记录: |