title: Plotting Time-series with POSIXct Date and Time Labels on x-axis
body: <p>I have data in the following format:</p>
  <blockquote>
  <p>my.XYZ$datetime&lt;- as.POSIXct(myXYZ$datetime, format = &quot;%Y-%m-%d %H:%M:%S&quot;)</p>
  <p>head(my.XYZ)</p>
  </blockquote>
  <pre><code>units            datetime
  1     1 0012-08-03 07:49:02
  2     1 0012-08-05 12:27:21
  3     1 0012-08-17 06:55:07
  4     1 0012-08-20 10:56:49
  5     1 0012-08-08 10:14:36
  6     1 0012-08-20 16:12:26
  </code></pre>
  <p>I want to create a time-series plot, with x-axis representing time&amp;date and y-axis units. This is what I did so far:</p>
  <pre><code>&gt; # make it a zoo object
  &gt; zoo.XYZ&lt;- zoo(my.XYZ)
  
  &gt; # make it a ts
  &gt; ts.XYZ&lt;- ts(zoo.XYZ)
  
  &gt; #plotting the ts object
  &gt; plot(ts.XYZ, plot.type=&quot;single&quot;)
  
  &gt;Warning messages:
  &gt; 1: In xy.coords(x = matrix(rep.int(tx, k), ncol = k), y = x, log = log) :
  &gt; NAs introduced by coercion
  &gt; 2: In xy.coords(x, y) : NAs introduced by coercion
  </code></pre>
  <p>Here I do get the right graph but my x-axis is not given by date but by variable's number (variable 1, 2, 3... 430)</p>
  <p>I also tried the following:</p>
  <pre><code>&gt;# plot as plot.ts
  &gt; plot.ts(ts.XYZ)
  
  &gt;Error in plot.window(...) : need finite 'ylim' values
  &gt;In addition: Warning messages:
  &gt;1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion
  &gt;2: In min(x) : no non-missing arguments to min; returning Inf
  &gt;3: In max(x) : no non-missing arguments to max; returning -Inf
  
  &gt; plot.ts(ts.XYZ, xaxt = &quot;n&quot;)
  
  &gt;Error in plot.window(...) : need finite 'ylim' values
  &gt;In addition: Warning messages:
  &gt;1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion
  &gt;2: In min(x) : no non-missing arguments to min; returning Inf
  &gt;3: In max(x) : no non-missing arguments to max; returning -Inf
  
  &gt; axis(1, my.XYZ$datetime, format(my.XYZ$datetime, &quot;%Y-%m-%d %H:%M:%S&quot;), cex.axis = .7)
  </code></pre>
  <p>Again, the graph is correct but the x-axis is not.</p>
  <p>Would somebody know how to handle this?</p>
  <p>Thank you.</p>
  <p>Giulia</p>