Skip to content
Prev 59944 / 398502 Next

labelling barplot

On Sat, 2004-11-27 at 08:59 +0000, Ross Clement wrote:
Draw your barplot, saving the bar midpoints in 'mp':

mp <- barplot( c( 2, 2, 0, 4, 2 ))


Now using axis(), label the x axis. Set 'at' to be the first and last
values in the 'mp' vector:

axis(1, labels = c(1, 5), at = c(mp[1], mp[length(mp)]))


Another alternative is to use mtext() instead of axis() like this:

mtext(side = 1, text = c(1, 5), at = c(mp[1], mp[length(mp)]), line = 1)


HTH,

Marc Schwartz