Reputation: 532
I would like to modify the part I marked in the image below. It's the gray part that I am talking about. If possible I would like to remove it or make it smaller, depending on how both results will look. This way I will have more space to perhaps add an extra row of plots. My code is below the image.
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"))
}
Upvotes: 1
Views: 2069
Reputation: 532
Based on the comment of Marco Sandri, the following removes the gray parts as well as the text. Within theme()
you must add: strip.background = element_blank(),
strip.text.x = element_blank()
. So the full code becomes (line 11 and 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"))
}
Upvotes: 4