我知道这不是一个数据可视化问题,但是老板要求它,所以我需要弄清楚它是否可能。
谢谢!
答案 0 :(得分:59)
2016年搜索的答案。
从ggplot2
2.0开始,switch argument将对facet_grid
或facet_wrap
执行此操作:
默认情况下,标签显示在图表的顶部和右侧。如果为“x”,则顶部标签将显示在底部。如果为“y”,则右侧标签将显示在左侧。也可以设置为“both”。
ggplot(...) + ... + facet_grid(facets, switch="both")
从ggplot2 2.2.0开始,
条带现在可以使用
facet_wrap()
自由定位在switch
strip.position参数(不赞成strip.position
)。
当前的文档仍为2.1,但开发文档中strip.position = c("top", "bottom", "left", "right")
为documented。
默认情况下,标签显示在图表的顶部。使用strip.position,可以通过设置
将标签放在四边之一上ggplot(...) + ... + facet_wrap(facets, strip.position="right")
Parallel.ForEach(_xmlElementObject.Layout, dashboardItem =>
{
if (slaves.Contains(dashboardItem.ReportName))
{
ServiceHub.Send(dashboardItem.ReportName, GetWidgetData(dashboardItem, null, null, null, null, viewerActions.Select(viewerAction => viewerAction.Control == dashboardItem.ReportName && viewerAction.ErrorOccurred).Any()));
}
}
答案 1 :(得分:1)
您现在可以使用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"
)
答案 2 :(得分:-1)
答案是肯定的!
theme(strip.text=element_text(vjust=-10))
数字-10由您在地块中使用的比例和单位决定。
答案 3 :(得分:-3)
继续使用主题:
主题(strip.text = element_text(vjust = -10))
确保您的标签都具有相同的回车数。
Label /n Facet /n One
的价格与Label /n Facet Two
不同。