相关疑难解决方法(0)

有没有办法增加一个方面的strip.text栏的高度?

我希望顶部的灰色条更宽,因为它的边缘距离字母的顶部和底部稍远一些(strip.text - A,B,C等).我本以为行高会起到填充的作用,但事实并非如此.

ggplot(diamonds, aes(carat, price, fill = ..density..)) +
  xlim(0, 2) + stat_binhex(na.rm = TRUE)+
  facet_wrap(~ color) +
  theme(strip.text = element_text(lineheight=20)) 
Run Code Online (Sandbox Code Playgroud)

r ggplot2

14
推荐指数
1
解决办法
3236
查看次数

编辑条带大小ggplot2

我试图应用这个解决方案(如何在ggplot中更改小平面上的条带大小1)更改ggplot中小平面上的条带大小,我增加了高度大小

library(ggplot2)
library(gtable)

d <- ggplot(mtcars, aes(x=gear)) + 
            geom_bar(aes(y=gear), stat="identity", position="dodge") +
            facet_wrap(~cyl)

g <- ggplotGrob(d)
g$heights[[3]] = unit(5,"in")

grid.newpage()
grid.draw(g)
Run Code Online (Sandbox Code Playgroud)

这是我得到的,它只增加了条带顶部的空白(白色): 在此输入图像描述

为什么它的工作方式不同?

r ggplot2

13
推荐指数
1
解决办法
6413
查看次数

更改ggplot2中条带文本背景的高度不能按预期工作

###Load libraries

library(ggplot2)
library(gtable)

###Build plot

d <- ggplot(mtcars, aes(x=gear)) + 
            geom_bar(aes(y=gear), stat="identity", position="dodge") +
            facet_wrap(~cyl)

###Change height of strip text

g <- ggplotGrob(d)
g$heights[[3]] = unit(2,"in")
grid.newpage()
grid.draw(g)
Run Code Online (Sandbox Code Playgroud)

获得的结果(ggplot2_2.0.0)

在此输入图像描述

预期结果(ggplot2_1.0.1)

在此输入图像描述

中土世界到底发生了什么?

r ggplot2 gtable

5
推荐指数
1
解决办法
487
查看次数

标签 统计

ggplot2 ×3

r ×3

gtable ×1