有没有办法在一个方面增加strip.text栏的高度? [英] Is there a way to increase the height of the strip.text bar in a facet?

查看:148
本文介绍了有没有办法在一个方面增加strip.text栏的高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望顶部的灰色条更宽一些,因为它的边缘距字母的顶部和底部稍远(strip.text - A,B,C等)。

I would like the grey bar at the top to be wider, as in, have the edges of it a little further from the top and bottom of the letters (the strip.text - A, B, C etc). I would have thought the lineheight would have acted as padding but it doesn't.

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)) 


推荐答案

这些级别包含一个换行符:

First, modify the levels so that they include a linebreak:

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

然后根据需要进行调整。例如:

Then adjust as necessary. eg:

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))

这篇关于有没有办法在一个方面增加strip.text栏的高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆