can I change the position of the strip label in ggplot from the top to the bottom?

萝らか妹 提交于 2019-11-28 21:00:42
Dave

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")
brainSci

The answer is yes!

theme(strip.text=element_text(vjust=-10))

The number -10 is determined by the scale and units you're using in your plot.

Mark Wagner

To follow on the use of theme:

theme(strip.text=element_text(vjust=-10))

Be sure your labels all have the same number of carriage returns.

Label /n Facet /n One will vjust at a different rate than Label /n Facet Two.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!