1

Here is my code. I'm getting the plot I want but it doesn't have a legend for the colors. I have Grade.7.ELA.4s...White as green and Grade.7.Math.4s as blue and thought the scale_color_manual would create a legend but when I plot it no legend appears.

  PerW.vs.7ELA4s <- ggplot(Explore, aes(Explore$Percent.White, value)) +
  geom_point(aes(Percent.White, Grade.7.ELA.4s...White), 
     color="green", alpha=.55) +
  geom_point(aes(Percent.White, Grade.7.Math.4s...White), 
     color="blue", alpha=.5) +
  geom_smooth(aes(Percent.White, Grade.7.ELA.4s...White), 
     color="green", alpha=.55, se=F) +
  geom_smooth(aes(Percent.White, Grade.7.Math.4s...White), 
     color="blue", alpha=.5, se=F) +
  scale_color_manual(name="", values=c("ELA"="green", "Math"="blue")) +
  labs(y="# 7th Grade ELA 4's", x="Percent White")
  • 2
    Try mapping color to a variable and then use `scale_color_manual`. – Roman Luštrik Aug 21 '18 at 07:17
  • Possible duplicate of [ggplot legend - scale\_colour\_manual not working](https://stackoverflow.com/questions/33703853/ggplot-legend-scale-colour-manual-not-working) – markus Aug 21 '18 at 07:40
  • Possible duplicate of [change both legend titles in a ggplot with two legends](https://stackoverflow.com/questions/6910988/change-both-legend-titles-in-a-ggplot-with-two-legends) – Sal-laS Aug 21 '18 at 07:54

0 Answers0