[R] numbers on barplot

John Kane jrkrideau at yahoo.ca
Mon Jul 27 16:24:20 CEST 2009


names(dat)<-c("NumberOfPeople","Average")
Graph<-barplot(dat$Average)
barplot(dat$Average, ylim=c(0,max(dat[,2]+.2)))
text(Graph, dat[,2],  dat[,1], pos=3)

The reason for the ylim is so that the number for the righthand bar does not go outside the plot area.

--- On Mon, 7/27/09, Mohsen Jafarikia <jafarikia at gmail.com> wrote:

> From: Mohsen Jafarikia <jafarikia at gmail.com>
> Subject: [R] numbers on barplot
> To: R-help at stat.math.ethz.ch
> Received: Monday, July 27, 2009, 10:01 AM
> Hello all,
> I have this simple barplot code:
> 
> ifn <- "id.dat"
> dat <- read.table(ifn)
> ofn <- "id.png"
> 
> bitmap(ofn, type = "png256", width = 30, height = 30,
> pointsize = 30, bg =
> "white",res=50)
> par(mar=c(5, 5, 3, 2),lwd=5)
> par(cex.main=1.6,cex.lab=1.6,cex.axis=1.6)
> 
> names(dat)<-c("NumberOfPeople","Average")
> Graph<-barplot(dat$Average)
> dev.off()
> 
> and here is the data (id.dat):
> 
> 15    0.08
>  6    0.09
>  7    0.37
> 
> I want to write down the ""NumberOfPeople" on top of each
> of the bars. Can
> anybody help me on this?
> 
> Thanks,
> Mohsen
> 
>     [[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org
> mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
> 


      __________________________________________________________________
Looking for the perfect gift? Give the gift of Flickr! 

http://www.flickr.com/gift/




More information about the R-help mailing list