我试图应用这个解决方案(如何在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)
为什么它的工作方式不同?
wic*_*ici 25
一个简单的解决方案是strip.text
适当地指定元素的边距:
ggplot(mtcars, aes(x=gear)) +
geom_bar(aes(y=gear), stat="identity", position="dodge") +
facet_wrap(~cyl) +
theme(strip.text.x = element_text(margin = margin(2,0,2,0, "cm")))
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6413 次 |
最近记录: |