Tell me more ×
Cross Validated is a question and answer site for statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.

Consider the following code:

require(zoo)
data <- read.csv(file="summary.csv",sep=",",head=TRUE)
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:

alt text

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?

share|improve this question
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

2 Answers

up vote 2 down vote accepted

For the second Q, you can use axis.Date() with argument labels = FALSE to add minor tick marks at locations defined by argument at.

share|improve this answer
(+1) Good to know, thx. – chl Nov 13 '10 at 18:12

For the first question try:

plot(data2,xlab='',ylab='entropy (bytes)', xaxs = 'i', yaxs = 'i')
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.