-1

My data consists of the variables log R ratio, sample_id and replicate. I have made a boxplot with ggplot.

replicate_to_R$replicate <-factor(replicate_to_R$replicate, levels=c( "3", "4", "8","12" ), labels=c("3", "4", "8","12"))

replicate_to_R$sample_id <-factor(replicate_to_R$sample_id, levels=c(74,76,78,79,80), labels=c(18,20,22,23,24))
# boxplot
ggplot(aes(y=logRratio, x=sample_id, fill=replicate), data=replicate_to_R) + 
geom_boxplot(outlier.shape=NA) + scale_y_continuous(limits=c(-1,1)) + 
scale_fill_manual(values=c("steelblue4","steelblue3","steelblue2","steelblue1")) + theme(panel.grid.major.x =element_blank()) + 
theme(panel.background = element_blank()) + 
theme(axis.text = element_text(size=14, color="black")) 

I want to add information on call rate for each sample in the top of the plot. Is there a way to add this additional information to the plot?

Jaap
  • 81,064
  • 34
  • 182
  • 193
  • 2
    [`geom_text`](http://docs.ggplot2.org/current/geom_text.html) might be quite usefull for this. Furthermore, a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610#5963610) would be nice – Jaap May 18 '15 at 11:09

1 Answers1

0

ggplot2 graphics use the grid graphics system, so you can use grid functions to annotate them:

library("grid")
grid.text("my text", x = 0.5, y = 0.5)

will put your text dead center in the graphics window. See ?grid.text after loading the package for details about the coordinate system, but basically, the default system is relative to the entire graphics window.

Bryan Hanson
  • 6,055
  • 4
  • 41
  • 78