I am making a facet plot and trying to select the color I want for each plot (olivegreen and olivegreen3 in this case). I need to plot temp versus lat faceted by year
library(tidyverse)
d.f. <- data.frame( year = c(rep(2013, 10),rep(2015,10)), temperature = rep(c(1:10),2), lat = rep(c(70:79),2))
ggplot(data = d.f., aes(x=temperature, y = lat)) +
geom_point(show.legend = FALSE, size = 3) +
facet_wrap(~year) +
xlab("Surface Temperature") +
ylab("Latitude")
I am sure it is a simple fix, and perhaps I'm tired this Friday but I cannot figure out how to make the points in each facet different colors of my choosing. When I do color = year in the aes() argument that makes them unique colors, but automatically picked.
By default, year will be a numeric vector, so you'll need to coerce year to a factor. Then you can configure the color scale manually:
ggplot(data = d.f., aes(x=temperature, y = lat, color = factor(year))) +
geom_point(show.legend = FALSE, size = 3) +
scale_color_manual(values = c("darkolivegreen", "darkolivegreen3"))+
facet_wrap(~year) +
xlab("Surface Temperature") +
ylab("Latitude")