[R] R graphics: Add labels to stacked bar chart

Jens Oldeland oldeland at gmx.de
Thu Sep 2 12:50:24 CEST 2010


Hi,

I am looking for a way to add labels, i.e. absolute values, into a 
stacked bar chart using the basic plot functions of R. The labels should 
be inside the stacked bars.

For example,

###  I have this dataset

height = cbind(x = c(465, 91) / 465 * 100,
                       y = c(840, 200) / 840 * 100,
                       z = c(37, 17) / 37 * 100)

### and use this plot
barplot(height,
        beside = FALSE,
        horiz=T,
        col = c(2, 3)
        )
     
how can I put the values from height within the respective stacked bars?

Thank you!

-- 
+++++++++++++++++++++++++++++++++++++++++
Dipl.Biol. Jens Oldeland
Biodiversity of Plants
Biocentre Klein Flottbek and Botanical Garden
University of Hamburg 
Ohnhorststr. 18
22609 Hamburg,
Germany

Tel:    0049-(0)40-42816-407
Fax:    0049-(0)40-42816-543
Mail: 	Oldeland at botanik.uni-hamburg.de
        Oldeland at gmx.de 	(for attachments > 2mb!!)
Skype:	jens.oldeland
http://www.biologie.uni-hamburg.de/bzf/fbda005/fbda005.htm
http://jensoldeland.wordpress.com
+++++++++++++++++++++++++++++++++++++++++



More information about the R-help mailing list