# NOT RUN {
# simple vector
x <- c(453, 44, 56, 34)
b <- barplot(x)
BarText(x, b, x)
# more complicated
b <- barplot(VADeaths, horiz = FALSE, col=hblue, beside = TRUE)
BarText(VADeaths, b=b, horiz = FALSE, beside = TRUE, cex=0.8)
BarText(VADeaths, b=b, horiz = FALSE, beside = TRUE, cex=0.8, pos="bottomin",
col="white", font=2)
b <- barplot(VADeaths, horiz = TRUE, col=hblue, beside = TRUE)
BarText(VADeaths, b=b, horiz = TRUE, beside = TRUE, cex=0.8)
b <- barplot(VADeaths)
BarText(VADeaths, b=b)
b <- barplot(VADeaths, horiz = TRUE)
BarText(VADeaths, b=b, horiz = TRUE, col="red", cex=1.5)
# position of the text
par(mfrow=c(3,2))
off <- c(10, 4, 1, 20, -15)
for(pos in eval(formals(BarText)$pos)) {
b <- barplot(x, offset=off,
main=gettextf("Textposition pos = '%s'", pos), horiz=TRUE)
abline(h=0)
BarText(x, b, x, offset = off, pos=pos, cex=1.5, horiz=TRUE)
}
# }
Run the code above in your browser using DataLab