r - ggplot: how to add direct labels to each curve -


i trying add direct label each curve in density plot. label plots in tutorial, can't worked.

here data frame:

 values <- runif(1200, 35, 60)  ind <- as.factor(rep(c(1:6), each=200))  inout <- as.factor(rep(c(1:2), each =600))  df <- data.frame(values,ind,inout) 

here density plot:

 ggplot(df) +      geom_density(aes(x=values, group=interaction(ind,inout), colour=factor(inout)), alpha=1) +     geom_density(aes(x=values, group=inout, fill=factor(inout)), alpha=.4) +     theme(text = element_text(size=25)) +      theme(legend.justification=c(1,1), legend.position=c(1,1)) +      guides(colour=false) +     scale_fill_discrete(name="ave.",breaks=c("1", "2"),labels=c("s1", "s2")) 

how can add direct labels (i.e., 1 6) each curve 2 groups (i.e., s1 , s2)? 2 averaged curves don't need labeled.

thanks lot.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -