on-internet
← Community

How to specify different background colors for each facet label in ggplot2?

Stack Overflow ·

A plot will be made from these data: library(ggplot2) mtcars %>% gather(-mpg, key = "var", value = "value") %>% ggplot(aes(x = value, y = mpg)) + geom_point() + facet_wrap(~ var, scales = "free") + theme_bw() How can I change the gray color of the titles of the panels for instance panels of am and hp green panels of gear drat disp red panels of vs wt blue panels cyl qsec carb black add a legend green = area red = bat blue = vege black = indus

Comments

Sign in or sign up to comment and upvote.

No comments yet.