title: R Plot Specify number of time tickmarks - time/date equivalent to pretty
body: <p>I was wondering how I could plot more tick marks when plotting time on the x-axis.</p>
  
  <p>Basically, a time equivalent to pretty. Pretty obviously doesn't work so well with times, as it uses factors of 1,2,5 and 10. For time one probably wants e.g. hours, half hours, ...</p>
  
  <pre><code>plot(as.POSIXct(x,origin="1960-01-01"),y,type="l",xlab="Time")
  </code></pre>
  
  <p>gives really too few and widely spaced tickmarks.</p>
  
  <pre><code>zoox&lt;-zoo(y,as.POSIXct(stats$Time,origin="1960-01-01"))
  plot(zoox)
  </code></pre>
  
  <p>gives the same.</p>
  
  <p>Thanks</p>
  
  <p>EDIT:</p>
  
  <p>Just to clarify (so far answers don't address my issue): What I am looking for is a function like pretty for dates, e.g. a function, that takes a start date, an end date, a number of ticks, and outputs the location of the ticks. That is, I am well aware it is possible to plot hours, to plot minutes, and what else, but pretty automates the tick distance for numbers, and a resulting function for dates should decide by itself whether to use days, hours, minutes, second, milliseconds, microseconds, 30 minutes, 500 micros, 5 seconds, etc. intervals. That is what pretty does for numbers, anyway.</p>
  
  <p>EDIT2:</p>
  
  <p>This is the function I currently use to decide the format for the time axis (note that this doesn't work for dates):</p>
  
  <pre><code>mydiff &lt;- end-start
  if(mydiff&gt;1800) {
      axis.POSIXct(1,xrange,format="%H:%M")
  } else if(mydiff&gt;30) {
      axis.POSIXct(1,xrange,format="%H:%M:%S")
  } else if(mydiff&gt;0.5) {
      axis.POSIXct(1,xrange,format="%H:%M:%OS3")
  } else
      axis.POSIXct(1,xrange,format="%H:%M:%OS6")
  }
  </code></pre>
  
  <p>I don't have a function that increase tick marks, so I use the default number of tick marks</p>