[R] Number above the bar?

Juliet Hannah juliet.hannah at gmail.com
Sun Nov 14 16:01:29 CET 2010


Check out ggplot2, specifically geom_bar and geom_text.

http://had.co.nz/ggplot2/

You have to get used to its syntax, which can take some time, but
after that it can make things a lot easier. Here is an example.

library(ggplot2)

df <- data.frame(xvar = factor(c(1, 2)),
yvar = c(1, 5))

p <- ggplot(df, aes( y=yvar, x=xvar))
p <- p + geom_bar( stat="identity")
p <- p + geom_text(aes(y=yvar+1,label=yvar))
p


On Thu, Nov 11, 2010 at 4:03 AM, Joel <joda2457 at student.uu.se> wrote:
>
> Hi
>
> I got an barplot, and I would like to have the exact number of the bars just
> above the bars anyone know how to do this?
>
> Sorry for bad English, and I do hope that you understand what im after.
>
> //Joel
> --
> View this message in context: http://r.789695.n4.nabble.com/Number-above-the-bar-tp3037438p3037438.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list