Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
有没有办法增加刻面中strip.text条的高度?_R_Ggplot2 - Fatal编程技术网

有没有办法增加刻面中strip.text条的高度?

有没有办法增加刻面中strip.text条的高度?,r,ggplot2,R,Ggplot2,我希望顶部的灰色条更宽一些,例如,它的边缘离字母的顶部和底部稍远一些(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))

我希望顶部的灰色条更宽一些,例如,它的边缘离字母的顶部和底部稍远一些(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)) 

首先,修改标高,使其包含换行符:

levels(diamonds$color) <- paste0(" \n", levels(diamonds$color) , "\n ")

使用
ggplot2
2.2.0,您可以使用
标签机来应用Ricardo的技巧,而无需修改数据帧:

P <- ggplot(diamonds, aes(carat, price, fill = ..density..)) +
  xlim(0, 2) + stat_binhex(na.rm = TRUE)+
  facet_wrap(~ color, labeller = labeller(color=setNames(paste0("\n", levels(diamonds$color), "\n"), levels(diamonds$color))))

P +  theme(strip.text = element_text(size=9, lineheight=0.5))

P增加文本大小本身并不令人满意?@alexwhan,增加文本大小也会增加条带大小,但不会改变条带的比率two@RicardoSaporta,同意-我喜欢你的解决方案延迟回复我。。。谢谢,一个肮脏的解决方案让我们诚实的哈哈,但一定要完成工作。谢谢你的帮助。
P +  theme(strip.text = element_text(size=9, lineheight=3.0))
P <- ggplot(diamonds, aes(carat, price, fill = ..density..)) +
  xlim(0, 2) + stat_binhex(na.rm = TRUE)+
  facet_wrap(~ color, labeller = labeller(color=setNames(paste0("\n", levels(diamonds$color), "\n"), levels(diamonds$color))))

P +  theme(strip.text = element_text(size=9, lineheight=0.5))