I want to add the legend next to my plot in order to be able to show which color is explaining each variable. How can I do that? Here's my code:
scatter = ggplot(vehicles, aes(x = seq(1,108)))
geom_point(aes(y = RV),size = 2,color = "blue" )
geom_point(aes(y= BOP), size = 2, color = "red")
scatter
I just obtained my plot but without the names in it
CodePudding user response:
It would be clearer if you can provide the vehicles data as well but I'm guessing this would work:
scatter = ggplot(vehicles, aes(x = seq(1,108)))
geom_point(aes(y = RV, colour = "RV"),size = 2 )
geom_point(aes(y= BOP, colour = "BOP"), size = 2)
scatter