# Adjusting axis properties in a timeseries graph

Consider the following code:

require(zoo)
data = zoo(data$compressed, as.Date(data$date))
data <- aggregate(data, identity, tail, 1)
days = seq(start(data), end(data), "day")
data2 = na.locf(merge(data, zoo(,days)))

par(bty = 'n')
plot(data2,xlab='',ylab='entropy (bytes)')


How can one:

1. Adjust both the horizontal and vertical limits o the drawn axis to match the start and end of data (as an example, while the y value may vary between 20 and 1525, the axis shows 0 and 1500).
2. Increase the horizontal resolution (at least add some minor ticks) when the timeseries spans for a couple of years.

Using:

plot(data2,xlab='',ylab='entropy (bytes)', xaxs = 'i', yaxs = 'i')


I get:

Which is not exactly what I had in mind. The vertical scale doesn't start with the exat minimum (around 25), nor does it end with the exact maximum. The horizontal scale starts and ends in the middle. Hints?

-
Don't confuse the pretty label locations for the data. The figure region has been set to the range of the data. If you want axes with labels at specific, predefined points, turn off axis drawing in the plot() call with axes = FALSE and then draw the axes using axis(side = 2) for the y axis with suitable at, and the x-axis can be drawn using axis.Date() as per my answer below. –  Gavin Simpson Nov 13 '10 at 22:48

For the second Q, you can use axis.Date() with argument labels = FALSE to add minor tick marks at locations defined by argument at.
plot(data2,xlab='',ylab='entropy (bytes)', xaxs = 'i', yaxs = 'i')