I'm not sure why I'm getting my colors backward. Can someone please explain how the colors are assigned in this code? I'm trying to use examples on ggplot2 reference site, but I've been stuck on this for a long time. Here's the code:
#libraries
library(ggplot2)
library(scales)
library(reshape2)
#data
client.data <- read.csv('client.total.sorted.csv', header = TRUE, sep = ",")
#plot
ggplot(data = client.sorted) +
geom_smooth(mapping = aes(x = Date, y = Cancelled, color = "red")) +
geom_point(mapping = aes(x = Date, y = Cancelled, color = "red")) +
geom_smooth(mapping = aes(x = Date, y = Active, color = "green")) +
geom_point(mapping = aes(x = Date, y = Active, color = "green")) +
labs(title = "activations vs cancellations", x = "Date", y = "")
I found this post referencing legends that helped me solve this:
Add legend to ggplot2 line plot
The solution that worked for me is this: