37

次のタイプのプロットがあり、個々のファセットボックスの上に各ストリップテキストを一種の「タイトル」として保持したいが、デフォルトの灰色の背景とstrip.background. strip.background希望に近い白に色付けしますが、 の下端または上端panel.borderを黒にしたいと思います。

ここに画像の説明を入力

library(ggplot2)

ggplot(mtcars, aes(mpg, hp)) + geom_point() +
    facet_wrap(~carb, ncol = 3) + theme_bw() +
    theme(panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        strip.background = element_rect(colour="white", fill="white"),
        panel.border = element_rect(colour = "black"))
4

3 に答える 3

53

設定element_blank()strip.backgroundて保持element_rect(colour="black", fill = NA)するとpanel.border、上端panel.borderが黒くなります。@adrien が指摘したようpanel.backgroundに、ポイントをカバーしないようにするには、fill を NA に設定する必要があります (既に のデフォルトとして設定されていますtheme_bw())。

ggplot(mtcars, aes(mpg, hp)) + geom_point() +
  facet_wrap(~carb, ncol = 3) + theme_bw() +
  theme(panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        strip.background = element_blank(),
        panel.border = element_rect(colour = "black", fill = NA))

ここに画像の説明を入力

于 2013-01-06T19:20:24.680 に答える