2

I have the following plot, and I'm trying to

1) add labels to the dashed blue lines to show their value, preferably on the right side of each facet

2) reorder the facets by the mean, so that the facets appear in descending order of mean

require(ggplot2)
require(reshape)
set.seed(13)                                                                 
df <- data.frame(a=runif(10), b=rnorm(10), c=rbinom(10, 10, 0.1),            
             d=runif(10, -1, 1), date=as.Date("2000-01-01") + 0:9)       
df <- melt(df, id=c('date'))                                                 

g <- ggplot(df, aes(date, value)) + geom_line() + facet_wrap(~variable)      
g <- g + geom_line(stat='hline', yintercept='mean', color='blue', linetype=2)

enter image description here

1
  • 3
    This post answers your first question and this question answers your second question. (Be sure to read the answer to the second question before you jump to any conclusions.) Commented Jul 6, 2012 at 20:21

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.