Fran?ois Le Lay wrote:> Hi all,
>
> Could anybody help me figure out how to write text on a boxplot. I have to
> plot 9 boxplots side by side on a single graph. On the x-axis I write
numeric
> values with the 'names' argument but I'd like to add one label
(character
> value) in the middle of each box. I know how to use the text() function for
> regular y~x plots but in this particular case, I'm kinda lost...
> Here is my code:
>
> # creating labels for x-axis labelling
> lb <- c()
> for( n in names(o) )
> lb <- c(lb, paste("\n",n,"\n",o[[n]],
sep=""))
>
> boxplot(x[,-c(10,11)],
> varwidth=TRUE,
>
col=c("#FF0000","#EE0000","#DD0000","#00FF00","#0000FF","#0000DD","#0000BB","#000099"),
> col.lab="dark red",
> col.axis="blue",
> main="Boxplots for Polling results, 1868 clusters, 9604
simulated
> requests",
> names=lb,
> xlab="RED BOXPLOTS: precision dependent - GREEN BOXPLOT: null
radius -
> BLUE BOXPLOTS: percent of exact radius",
> ylab="P(ID) values")
>
>
> Thanks for your help,
> Fanch
>
As an example how to write text in the boxes directly below the median
line, I'd suggest to use:
temp <- boxplot(.... your boxplot arguments ....)
text(seq(along = temp$n), temp$stats[3, ],
labels = c("text.box.1", "text.box.2"), pos = 1)
Uwe Ligges