I'm trying to made the text in the legend the same colour as the line in a ggplot. Say the line for Female is green and male is blue then the text saying female would be green and male would be blue.
df1 <- data.frame(
sex = factor(c("Female","Female","Male","Male")),
time = factor(c("Lunch","Dinner","Lunch","Dinner"), levels=c("Lunch","Dinner")),
total_bill = c(13.53, 16.81, 16.24, 17.42))
ggplot(data=df1, aes(x=time, y=total_bill, group=sex, shape=sex, colour=sex)) +
geom_line()+
scale_color_manual("sex",values=c("green", "blue"))
Test code taken from: http://www.cookbook-r.com/Graphs/Legends_(ggplot2)/