[R] bars' values on barplot

Mark Wardle mark at wardle.org
Sun Aug 5 10:12:05 CEST 2007


Akki,

1. Have a look at the result from a barplot() call.

>From the help:
A numeric vector (or matrix, when beside = TRUE), say mp, giving the
coordinates of all the bar midpoints drawn, useful for adding to the
graph.

2. Have a look at the text() function that will annotate plots!


So, try this for starters:
my.values=1:5
x <- barplot(my.values, ylim=c(0,7))
text(x, 0.4+my.values, "wibble")

Hope this helps,

Best wishes,

Mark




On 04/08/07, akki <akkilesha at gmail.com> wrote:
> Hi,
> I need bars' values on barplot, and I don't know how I can put it. I do my
> barplot as:
>
> data<-read.table("/my_path/file.dat",header=T, sep="\t")
> barplot(as.matrix(data),log="y",beside=TRUE,main="my_title", xlab="x name",
> ylab="y name").
>
> How can I add the values on each bar?
>
> Thanks..
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email
> ______________________________________________________________________
>


-- 
Dr. Mark Wardle
Clinical research fellow and specialist registrar, Neurology
Cardiff, UK



More information about the R-help mailing list