0

I've seen a few posts answering this question but none of the answers seem to solve my issue. I am just trying to add a legend to this series of geom_point plots which indicates which colored points correlate to "BEAV-O1," "NORT-O1", etc.

NormalizedPlot<- ggplot()+ 
  geom_point(NormalizedNL, mapping= aes(x= NormalizedNL$Date,y= NormalizedNL$`BEAV-O1`), color = "blue") + 
  geom_point(NormalizedNL, mapping= aes(x= NormalizedNL$Date,y= NormalizedNL$`SAND-O1`), color = "cyan") +
  geom_point(NormalizedNL, mapping= aes(x= NormalizedNL$Date,y= NormalizedNL$`NORT-O1`), color = "cornflowerblue") +
  geom_point(NormalizedNL, mapping= aes(x= NormalizedNL$Date,y= NormalizedNL$`BELM-O1`), color = "red")+
  geom_point(NormalizedNL, mapping= aes(x= NormalizedNL$Date,y= NormalizedNL$`MERI-O1`), color = "maroon")+
  geom_point(NormalizedNL, mapping= aes(x= NormalizedNL$Date,y= NormalizedNL$`PATT-O1`), color = "darkred")+
  scale_y_log10() + xlab("Water Year") + ylab("Normalized Nitrate Load (%)") +theme_bw() + ggtitle("Site Normalized Annual Nitrate Load") + **scale_color_manual(name= "Legend", values = c("BEAV-O1"="blue", "SAND-O1"="cyan", "NORT-O1"= "cornflowerblue", "BELM-O1"="red", "MERI-O1"="maroon", "PATT-O1"="darkred"))**

NormalizedPlot
MrFlick
  • 195,160
  • 17
  • 277
  • 295
jaynesw
  • 43
  • 7
  • If you want a legend, `color=` needs to be inside the `aes()`. And since you are specifying color names, you can use ` + scale_color_identity()` to use those values in the plot. – MrFlick Mar 01 '23 at 19:34

0 Answers0