Please find a reprex below but this is what I currently have:
I don't need to have a separate legend for each of the plots but I would like the legend to be divided by the facets. It can just be by having a separate title:
Cash flow indicator ratios
Ratio xx
Ratio yy
Ratio zz
Growth ratios
Ratio aa
Ratio bb
Ratio cc
...
Does anyone have any suggestion on how to do that?
Thank you!!
REPREX:
mtcars$names <- rownames(mtcars)
mtcars <- mtcars %>%
mutate(group = case_when(gear == 3 ~ "A",
gear == 4 ~ "B",
gear == 5 ~ "C"))
ggplot(data = mtcars, aes(mpg, disp, color = names, group =group)) +
geom_line(size = 1) +
geom_point()+
guides(color=guide_legend(ncol=1))+
facet_wrap(~ group)
I would like to have the legend divided in Groups A, B, C.