我可以在ggplot中从上到下更改条形标签的位置吗? [英] can I change the position of the strip label in ggplot from the top to the bottom?

查看:391
本文介绍了我可以在ggplot中从上到下更改条形标签的位置吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这不是一个数据可视化问题,但是老板问了这个问题,所以我需要弄清楚是否有可能。



谢谢! / p>

解决方案

为2016年搜索者提供的答案。



code> ggplot2 2.0,切换参数将会对 facet_grid facet_wrap $ b


默认情况下,标签显示在图的顶部和右侧。如果x,顶部标签将显示在底部。如果y,则右侧标签将显示在左侧。也可设置为两者。




  ggplot(...)+ .. 。+ facet_grid(facets,switch =both)

自ggplot2 2.2.0


现在可以使用
strip.position参数将条带自由定位在 facet_wrap()中(弃用 switch

目前的文档仍然在2.1,但 strip.position 记录在开发者文档上。


默认情况下,标签显示在图的顶部。使用strip.position可以通过设置 strip.position = c(top,bottom,left,right)
$ b $ pre $ ggplot(...)+ ... + facet_wrap(方面,strip.position =right)


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.

Thanks!

解决方案

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

这篇关于我可以在ggplot中从上到下更改条形标签的位置吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆