I would like to rebuild / offset the x axis and its associated bar font marks. It should be simple, but it's hard for me to find the answer. Below are sample data with 24 categories.
xval = c(1:24)
count = c(0.03,0.03,0.08,0.06,0.11,0.4,0.3,0.5,0.5,0.6,0.4,0.1,0.1,0.4,0.2,0.1,0.06,0.05,0.03,0.02,0.01,0.03,0.01,0.02)
df = as.data.frame(cbind(xval, count))
I can easily create a barcode with label marks aligned at the midpoints of the bar using the code below:
mp <- barplot(df$count, space=0, axes=FALSE)
axis(side=2, pos=-0.2)
axis(side=1, at =mp, labels=df$xval)
I can also shift the entire X axis (marks and ticks) to align it with the external panel using the following (although now this does not allow the last stroke to be included in the axis):
axis(side=1, at =mp-0.5, labels=df$xval)
While I would like the x-axis and associated labels to be aligned with the borders of the strokes (i.e. the tick mark on both sides of the bar, and not in the center), I want the x-axis labels to remain at the midpoints of the bar . Is there an easy way to achieve this?