Re: [R] label option in 'barplot'?

From: Chuck Cleland <ccleland_at_optonline.net>
Date: Thu 18 Jan 2007 - 10:06:05 GMT

Justin Gengler wrote:
> Hello all,
>
> When using the 'barplot' function, how would one go about creating
> labels on the top of the bars corresponding to the actual frequency
> values (i.e., the height of the bar). For histograms, one can use
> the 'LABEL=T' parameter to this effect, but it is not available for
> barplot. Must one manually create such labels for a barplot (perhaps
> using mtext)?

  Yes, I believe you would need to add those labels yourself. Use text() rather than mtext() to get something similar to what hist() does when labels=TRUE. Here is how you could put the labels either just below or just above the top of the bar:

# Below
X <- barplot(VADeaths, beside=TRUE, ylim=c(0,80)) text(X, VADeaths, labels=VADeaths, pos=1, offset=.5, col="red")

# Above
X <- barplot(VADeaths, beside=TRUE, ylim=c(0,80)) text(X, VADeaths, labels=VADeaths, pos=3, offset=.5)

> Thanks.
>
> Justin Gengler
>
> ______________________________________________
> R-help@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.

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

______________________________________________
R-help@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.
Received on Thu Jan 18 21:19:42 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 18 Jan 2007 - 11:30:23 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.