An answer for those searching in 2016.
As of ggplot2
2.0, the switch argument will do this for facet_grid
or facet_wrap
:
By default, the labels are displayed on the top and right of the plot. If "x", the top labels will be displayed to the bottom. If "y", the right-hand side labels will be displayed to the left. Can also be set to "both".
ggplot(...) + ... + facet_grid(facets, switch="both")
As of ggplot2 2.2.0,
Strips can now be freely positioned in facet_wrap()
using the
strip.position argument (deprecates switch
).
Current docs, are still at 2.1, but strip.position
is documented on the dev docs.
By default, the labels are displayed on the top of the plot. Using strip.position it is possible to place the labels on either of the four sides by setting strip.position = c("top", "bottom", "left", "right")
ggplot(...) + ... + facet_wrap(facets, strip.position="right")
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…