ggplot v2.1.0以降の場合は、次を使用element_blank()
して不要な要素を削除します。
library(MASS) # To get the data
library(ggplot2)
qplot(
week,
y,
data = bacteria,
group = ID,
geom = c('point', 'line'),
xlab = '',
ylab = ''
) +
facet_wrap(~ ID) +
theme(
strip.background = element_blank(),
strip.text.x = element_blank()
)
この場合、削除しようとしている要素はと呼ばれstrip
ます。

ggplotgrobレイアウトを使用する代替
古いバージョンggplot
(v2.1.0より前)では、ストリップテキストはgtableレイアウトの行を占めます。
element_blank
テキストと背景を削除しますが、行が占めていたスペースは削除しません。
このコードは、これらの行をレイアウトから削除します。
library(ggplot2)
library(grid)
p <- qplot(
week,
y,
data = bacteria,
group = ID,
geom = c('point', 'line'),
xlab = '',
ylab = ''
) +
facet_wrap(~ ID)
# Get the ggplot grob
gt <- ggplotGrob(p)
# Locate the tops of the plot panels
panels <- grep("panel", gt$layout$name)
top <- unique(gt$layout$t[panels])
# Remove the rows immediately above the plot panel
gt = gt[-(top-1), ]
# Draw it
grid.newpage()
grid.draw(gt)