I know this is not quite a data visualization issue, but the boss asked for it, so I need to figure out if it is possible.
-
3http://groups.google.com/group/ggplot2/browse_thread/thread/a9a28e6b603d3e9d – apeescape Jul 16 '10 at 03:47
-
12ggplot2 is powerful but opinionated software- sometimes it is the ggplot way or no way at all. – Sharpie Jul 18 '10 at 19:32
-
agree, need to do some modification using grid then, another steep learning curve again – lokheart Jul 19 '10 at 05:34
-
See linked forum post in the comments in http://stackoverflow.com/questions/10058839/how-to-display-strip-labels-below-the-plot , which gives the required grid hackery – Ben Bolker May 09 '12 at 19:35
-
Using `gtable` functions, it is easy to move the strip. See [http://stackoverflow.com/.../how-to-display-strip-labels-below-the-plot-when-faceting/...](http://stackoverflow.com/questions/10058839/how-to-display-strip-labels-below-the-plot-when-faceting/29336396#29336396) or [here](http://stackoverflow.com/questions/29008683/ggplot2-using-gtable-to-move-strip-labels-to-top-of-panel-for-facet-grid/29022188#29022188) or [here](http://stackoverflow.com/questions/28853786/how-do-i-plot-charts-with-nested-categories-axes/28868462#28868462) – Sandy Muspratt Mar 29 '15 at 23:59
-
And [here](http://stackoverflow.com/questions/18065319/flip-facet-label-and-x-axis-with-ggplot2?lq=1) – Sandy Muspratt Mar 30 '15 at 02:51
-
2Could you please un-accept the accepted answer? It’s no longer correct, yet this answer is the top hit when googling for the question. – Konrad Rudolph Apr 14 '17 at 14:07
2 Answers
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 (deprecatesswitch
).
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")

- 1,199
- 2
- 14
- 38

- 2,396
- 2
- 22
- 25
-
122020 update - ggplot 3.3 - `facet_grid` [still uses](https://ggplot2.tidyverse.org/reference/facet_grid.html) `switch` with arguments of `x`, `y` or `both`. – nniloc May 21 '20 at 16:49
-
-
Now (with version 3.4.2), options are `switch = ` to "both", "x", or "y" – jgarces May 19 '23 at 11:28
you can now use facet_wrap(~var, strip.position = "bottom")
, though for some reason this results in the labels being located above the axis tick mark labels, rather than below (which I think would make more sense), as you can see from my screenshot of a small portion of my graph
If you want to have the label below, you have do to this
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"
)
As seen here: https://github.com/tidyverse/ggplot2/issues/2622