Summary: In R, I want ggplot to align the color of geom_point based upon a factor variable within the dataframe.
Here is an example of the data:
#CREATE VECTORS
C1<-c(2,2,2,1,1,0,0)
C2<-c(1,1,2,1,0,0,1)
C3<-c("YELLOW", "YELLOW", "GREEN","RED", "RED", "RED", "RED")
#COMBINE VECTORS - CREATE DATAFRAME
x<- data.frame(cbind(C1,C2,C3))
Use ggplot to create plot:
ggplot(x, aes(C1,C2)) +
geom_jitter(aes(color=C3)) +
geom_point(aes(color=C3))
I would like the C3 variable to choose the color in the plot, meaning GREEN=green, RED=red, and YELLOW = yellow
... + scale_colour_manual(values = c("GREEN" = "green", "RED" = "red", "YELLOW" = "yellow"))
- Russ Hyde