15

上部の灰色のバーを広くしたいのですが、その端を文字の上部と下部から少し離してください (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)) 
4

2 に答える 2

24

まず、改行が含まれるようにレベルを変更します。

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

線の高さ=0.5

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

lineheight=3.0

于 2013-07-24T04:59:55.307 に答える