Skip to content
Back to formatted view

Raw Message

Message-ID: <20090227132605.GA5421@localhost>
Date: 2009-02-27T13:26:05Z
From: Philipp Pagel
Subject: add absolute value to bars in barplot
In-Reply-To: <1B5F1031-9F89-487C-BC79-42867B8D7ABD@eawag.ch>

On Fri, Feb 27, 2009 at 01:32:45PM +0100, soeren.vogel at eawag.ch wrote:
> barplot(twcons.area,
>   beside=T, col=c("green4", "blue", "red3", "gray"),
>   xlab="estate",
>   ylab="number of persons", ylim=c(0, 110),
>   legend.text=c("treated", "mix", "untreated", "NA"))
>
> produces a barplot very fine. In addition, I'd like to get the bars'  
> absolute values on the top of the bars. How can I produce this in an  
> easy way?

barplot() returns a vector of midpoints so you can use text() to add the
annotation. There is an example in the manual page of barplot:

mp <- barplot(VADeaths)
tot <- colMeans(VADeaths)
text(mp, tot + 3, format(tot), xpd = TRUE, col = "blue")

cu
	Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl f?r Genomorientierte Bioinformatik
Technische Universit?t M?nchen
Wissenschaftszentrum Weihenstephan
85350 Freising, Germany
http://mips.gsf.de/staff/pagel