[R] barplot() and highlighted values

Sebastian Bergmann sb at sebastian-bergmann.de
Sat Apr 24 16:20:13 CEST 2010


Am 24.04.2010 16:01, schrieb Marc Schwartz:
> If you really want the values on top of the bars, use text() instead
> of mtext(). You will also need to increase the max value of the y axis 
> to make room for the labels using the ylim argument in barplot():
> costs <- c(1, 5, 10, 20, 50, 150)
> 
> mp <- barplot(costs, ylab = "Relative cost of a bugfix", 
>               names.arg = c("Requirements", "Design", "Code", "Developer Tests", 
>                             "Acceptance Tests", "Operations"),
>                           cex.names=0.6, ylim = c(0, max(costs) * 1.2))
> 
> text(mp, costs, labels = costs, pos = 3)

 This is exactly what I needed, thank you so much!

-- 
Sebastian Bergmann                    Co-Founder and Principal Consultant
http://sebastian-bergmann.de/                           http://thePHP.cc/



More information about the R-help mailing list