How can I centre the labels on the x-axis to match up with the bars? Also, how can I position the x axis label further down so it it is not obscured by the x-axis labels? Thanks!
par(mar= c(15,4,4,2) + 0.1)
barplot(58:1,xaxt="n",xlab="",ylab="Frequency", col=gray(5:0/5))
axis(1, labels=FALSE)
text(1:58, par("usr")[3] - 0.25, srt = 90, adj = 1,
labels = rep("Long Species Name",58), xpd = TRUE)
mtext(1, text = "Species", line=6)

Check out the return value of
barplot()(by reading?barplot). There we find that the mid points of the bars are returned by the function as a vector. Hence it is a simple matter of assigning the returned object (here to objectbar) and then use that in a call toaxis()to locate the tick marks.In the
axis()call, note that we specify both thelabelsargument and theatargument, withatbeing set to the bar mid points as stored inbar.las = 2is used to rotate the labels relative to the axis, andcex.axis = 0.6is used to reduce the label size.The second part of your question is handled by
title()and thelineargument. First note that when you set themarparameter you are setting the margin size in “lines”, hence the margin on side 1 (bottom) is 15 lines. Thelineargument intitle()specifies which of the margin lines you want to draw the axis label.Putting this altogether with a modified example we have:
Which produces: