Skip to content

mtext in barplot

3 messages · johnhj, Uwe Ligges, Jim Lemon

#
Hii,

Can anybody help me to put a text under the barplots. I will describe the
percental between six grouped barplots. I tried to do it with mtext but
without success.

Here is my code:

test <-read.table(file="D:/mobile.txt")

pdf(file = "D:/mobil126.pdf",
    width = 6.67, height = 5, onefile = TRUE, family = "Helvetica",
    title = "R Graphics Output", fonts = NULL, version = "1.1",
      bg="white", pointsize=10)

barplot(as.matrix(test), main="OLSR",xlab="Hops",
col=c("skyblue1","salmon"),width<-
c(1,1),names=c("2->1","4->2","3->1","2->1","2->1","1->2"),  legend =
rownames(x), beside=TRUE)

legend("topright", c("OLSR"),cex=0.8,ncol =1.5,col =
c("red"),bg=c("lightskyblue1"))

dev.off()


I tired to do it with 
mtext(side=1,at=x, text =c("Mean", "","","","","rere"), col = "red"),
line = 1, cex = 0.75) but without success, I get this example from a R
tutorial...

Can anybody help me please ?

greetings,
johnh
#
johnhj wrote:
What is x? The bars in a barplot are at locations 1:n.

Uwe Ligges
#
johnhj wrote:
Hi John,
The horizontal bar positions are returned invisibly by the barplot 
function, so:

xpos<-barplot(...)
mtext(side=1,at=xpos,...)

should do what you want.

Jim