r - How to change the text in the colour legend of ggplot2 -


i have code:

ggplot(databoth, aes(withxstep)) +         geom_point(aes(y = withnassoc, colour = "withnassoc"), size = 2.8) +         geom_point(aes(y = withoutnassoc, colour = "withoutnassoc"), size = 1 ) +        labs(colour = "legend") +        labs(x = "time") +        labs(y = "n associations") 

how modify withnassoc , withoutnassoc? "with activities" , "without activities".

this should answer question:

ggplot(databoth, aes(withxstep)) +         geom_point(aes(y = withnassoc, colour = "withnassoc"), size = 2.8) +         geom_point(aes(y = withoutnassoc, colour = "withoutnassoc"), size = 1 ) +               labs(colour = "legend", x = "time", y = "n associations") +               scale_color_manual(values = c("red", "blue"),                                   labels = c("with activities", "without activities")) 

for example data-set:

exampledata <- structure(list(withxstep = structure(c(4l, 3l, 2l, 1l),  .label = c("2017-06-27", "2017-06-28", "2017-06-29", "2017-06-30"), class = "factor"),  withnassoc = c(1, 2, 3, 4), withoutnassoc = c(5, 6, 7, 8)), .names = c("withxstep",  "withnassoc", "withoutnassoc"), class = "data.frame", row.names = c(na,-4l)) 

this plot:

enter image description here


Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -