I have regions as categorical variable and multiple countries under each region. If I plot multiple line chart for each region using facet_wrap I can see a plot per region but the legend is quite obscure as its not organised as per Regions. How can I break the legends for each plot in facet_wrap
showing only the countries within that group.
- I tried to manually colour the countries to make more sense (as by default same colours are repeated but didn't help)
Below is the code I tried for problem 2 but it didn't help.
ggplot(data = temp_tidy, aes(x= year,y= population)) +
geom_point()+geom_line(aes(group=`Country of birth`)) facet_grid(Major_Region_New~. )+
scale_color_manual(values = c("red","blue","green","brown","yellow","pink","seagreen1",
"gold1","sienna2","tomato","plum4","purple2"))
Actual plot should be 4 legends with 3 countries under each.