DescTools (version 0.99.19)

BarText: Add Text to a Barplot

Description

Places some text directly on the (stacked) bars of a barplot.

Usage

BarText(height, b, labels = height, beside = FALSE, horiz = FALSE, ...)

Arguments

height
either a vector or matrix of values describing the bars which make up the plot exactly as used for creating the barplot.

b
the returned mid points as returned by b <- barplot(...).

labels
the labels to be placed on the bars.

beside
a logical value. If FALSE, the columns of height are portrayed as stacked bars, and if TRUE the columns are portrayed as juxtaposed bars.

horiz
a logical value. If FALSE, the bars are drawn vertically with the first bar to the left. If TRUE, the bars are drawn horizontally with the first at the bottom.

...
the dots are passed to the text.

Details

It sometimes makes sense to place the results directly on the bars.

See Also

help

Examples

Run this code
b <- barplot(VADeaths)
BarText(VADeaths, b=b)

b <- barplot(VADeaths, horiz = TRUE)
BarText(VADeaths, b=b, horiz = TRUE, col="red", cex=1.5)

Run the code above in your browser using DataLab