我想修改下面图片中标记的部分。这是我所说的灰色部分。如果可能的话,我想将其删除或缩小,具体取决于两种结果的外观。这样我就可以有更多空间来添加额外的一行图。我的代码在图片下方。
spaghetti_plot_multiple <- function(input, MV, item_level){
MV <- enquo(MV)
titles <- enquo(item_level)
input %>%
filter(!!(MV) == item_level) %>%
mutate(first_answer = first_answer) %>%
ggplot(.,aes( x = time, y = jitter(Answer), group = ID)) +
geom_line(aes(colour = factor(first_answer))) +
labs(title = titles ,x = 'Time', y = 'Answer', colour = 'Answer time 0') +
facet_wrap(~ ID, scales = "free_x")+
theme(strip.text = element_text(size = 8),
plot.title = element_text(hjust = 0.5, size = 20,
face = 'bold', color = 'black')) +
scale_colour_manual(values = c("1" = "cyan", "2" = "black",
"3" = "#ff7f00", "4" = "blue", '5' = "#e41a1c"))
}
答案 0 :(得分:4)
根据Marco Sandri的评论,以下内容删除了灰色部分以及文本。在theme()
中,您必须添加:strip.background = element_blank(),
strip.text.x = element_blank()
。所以完整的代码变成了(第11行和第12行):
spaghetti_plot_multiple <- function(input, MV, item_level){
MV <- enquo(MV)
titles <- enquo(item_level)
input %>%
filter(!!(MV) == item_level) %>%
mutate(first_answer = first_answer) %>%
ggplot(.,aes( x = time, y = jitter(Answer), group = ID)) +
geom_line(aes(colour = factor(first_answer))) +
labs(title = titles ,x = 'Time', y = 'Answer', colour = 'Answer time 0') +
facet_wrap(~ ID, scales = "free_x")+
theme( strip.background = element_blank(),
strip.text.x = element_blank(),
plot.title = element_text(hjust = 0.5, size = 20,
face = 'bold', color = 'black')) +
scale_colour_manual(values = c("1" = "green", "2" = "black",
"3" = "#ff7f00", "4" = "blue", '5' = "#e41a1c"))
}