Skip to content

How to add values on bar of groouped bar plot using mtext?

2 messages · Manish Gupta, Uwe Ligges

#
How to write values on bars using mtext?

Grouped Bar Plot
counts <- table(mtcars$vs, mtcars$gear) barplot(counts, main="Car
Distribution by Gears and VS",xlab="Number of Gears",
col=c("darkblue","red"),legend = rownames(counts), beside=TRUE, horiz=TRUE)

mtext(counts ) # But poistion is not at each bar.

How can i put corresponsing values on each bars of  plot?

Regards 




--
View this message in context: http://r.789695.n4.nabble.com/How-to-add-values-on-bar-of-groouped-bar-plot-using-mtext-tp4640014.html
Sent from the R help mailing list archive at Nabble.com.
#
On 11.08.2012 04:55, Manish Gupta wrote:
Look at the output of barplot, it returns the locations:

bp <- barplot(counts, main = "Car Distribution by Gears and VS",
         xlab = "Number of Gears", col = c("darkblue", "red"),
         legend = rownames(counts), beside = TRUE, horiz = TRUE)
bp
mtext(side = 2, at = bp, text = counts)



Uwe Ligges