This is probably one of those (rare) situations where you want to use a grid rather than ticks to better show your data. As @ dirk-eddelbuettel noted, setting labels with a good axis is tough, especially with such a density. You may also want your tags to be inside the plot, so the grid will slightly hide their density. The easiest grid to get is abline if you don't want to play with ggplot2, but these are uglier than the standard graphics in R (personal opinion). Also - make the plot wider. In fact, it’s better to also get rid of the box around the plot;) Below is Dirk’s approach:
png("strangeplot.png",width=800) #extend y-axis to fit inside labels and remove box plot(b,type="n",xaxt="n",yaxt="n",ylab="",xlab="",ylim=c(min(b)-30,max(b)),bty="n")) #use 'mpg' to get labels inside axis(1,time(b)[ind], format(time(b)[ind]), las=2, cex.axis=0.6,tick=F,mgp=c(0,-2.5,0)) axis(2,tick=F,las=1) #you locate lines slightly to the left of label... abline(h=seq(0,200,by=50),v=time(b)[ind]-0.5,col=gray(0.9)) #...so you need to add extra single line in the end abline(v=max(time(b)[ind])+0.5,col=gray(0.9)) #plot at the end to get it above grid points(b,type="l") dev.off()

source share