Question: This is more of a "how to use R" question than an actual hardcore statistics question, but I think the concentration of R masters here makes this a good forum for it. I'm refreshing a time series graphing package that currently uses gnuplot. The first step is getting somewhere close to the current graphs, and then I hope to be able to add more statistical analysis from R later.

Currently, the gnuplot-generated graphs look like this:

![alt text](https://i.stack.imgur.com/EkuiN.png)

The corresponding graph from R looks like this:

![alt text](https://i.stack.imgur.com/mqWEr.png)

I'm reasonably happy with this. What's missing is the legend stuff from below the gnuplot graph. I can add a legend saying "In" and "Out", but how to best present the average, maximal and minimal values? I could add horizontal lines to the graph and print the values inside the graph area, but the placement might interfere with the actual graph.

Answer: 
A quick and dirty way to paste some text and numerical results along the labels of your legend is to simply rename the factor levels. For instance,

```
df <- data.frame(x=rnorm(100), y=rnorm(100), f=gl(2,50))
df$f2 <- df$f
levels(df$f2) <- paste(levels(df$f), tapply(df$y, df$f, mean), sep=": ")
p <- ggplot(data=df) + geom_point(aes(x=x, y=y, color=f2))
p + opts(legend.position = 'bottom', legend.title=NULL)

```

You can add whatever you want into the new labels, such as mean, min, max, etc. (e.g., create a custom function, inspired from `summary()` that returns the values you want, and append them to `c("In","Out")`).
Try the [directlabels](http://directlabels.r-forge.r-project.org/) package for some more control. As far as the caption goes, if you're automatically generating the graphs, you might simply use it as caption text (in LaTeX or HTML or what have you). Hope this helps.