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
--
View this message in context:
http://www.nabble.com/mtext-in-barplot-tp22893563p22893563.html
Sent from the R help mailing list archive at Nabble.com.
johnhj wrote:> 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...What is x? The bars in a barplot are at locations 1:n. Uwe Ligges> Can anybody help me please ? > > greetings, > johnh
johnhj wrote:> 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. > > ... > 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... >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