advanced patterns with `ggplot2` when using `facet_wrap` and `scale_color_manual`
I'm working through a tutorial and I'm refactoring my project and I'm sure I'm missing something obvious here, but I'm experiencing an scenario where the colors assigned using `scale_color_manual` in `ggplot2` are not applying correctly when I use `facet_wrap()`..... I'm trying to create a faceted plot where each facet represents a different `group`, but the color mapping doesn't seem to respect the manual scale I've set. Here's a minimal example of my code: ```r library(ggplot2) # Sample data set.seed(42) data <- data.frame( x = rep(1:10, 2), y = c(rnorm(10), rnorm(10, mean = 3)), group = rep(c("A", "B"), each = 10) ) # Attempting to create the plot p <- ggplot(data, aes(x = x, y = y, color = group)) + geom_point() + facet_wrap(~ group) + scale_color_manual(values = c("A" = "red", "B" = "blue")) print(p) ``` When I run this code, I expect the points in facet A to be red and those in facet B to be blue. However, both facets are showing the same color for the points, and they seem to be defaulting to the ggplot defaults instead of the specified colors. I've checked that the `group` variable is indeed a factor, and I've also tried using `as.factor()` on it, but the scenario continues. I'm using `ggplot2` version 3.3.5 and R version 4.1.1. Is there something I'm missing here? Any help would be appreciated! For context: I'm using R on Ubuntu. Is there a better approach? This is part of a larger web app I'm building. Is there a better approach? For reference, this is a production REST API. I'd really appreciate any guidance on this.