我希望顶部的灰色条更宽,例如,它的边缘离字母的顶部和底部稍远一点(strip.text - A、B、C 等)。我原以为 lineheight 会起到填充的作用,但事实并非如此。
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))
最佳答案
首先,修改级别,使其包含换行符:
levels(diamonds$color) <- paste0(" \n", levels(diamonds$color) , "\n ")
然后根据需要进行调整。例如:
P <- ggplot(diamonds, aes(carat, price, fill = ..density..)) +
xlim(0, 2) + stat_binhex(na.rm = TRUE)+
facet_wrap(~ color)
P + theme(strip.text = element_text(size=9, lineheight=0.5))
P + theme(strip.text = element_text(size=9, lineheight=3.0))
关于r - 有没有办法在一个方面增加 strip.text 栏的高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17825201/