title: R setting xlim in xts plot
body: <p>I am trying to expand the X-axis of my time series plot to be prepared for adding new data into the plot later on. However, whatever I try I get the <strong>Error in plot.window(...) : invalid 'xlim' value</strong> error.</p>
  
  <p>Here is a minimal code snippet:</p>
  
  <p>Data construction:</p>
  
  <pre><code>time_series &lt;- xts(rnorm(100),seq(as.POSIXct("2012-01-01 00:00:00"), as.POSIXct("2012-01-05 03:00:00"), by="hour"))
  </code></pre>
  
  <p>Plotting:</p>
  
  <pre><code>plot(time_series, type='l');
  </code></pre>
  
  <p>The result is, as expected, a nice time series plot.</p>
  
  <p>Now, I wanted to expand the x-axis and I tried:</p>
  
  <pre><code>xlim &lt;- seq(as.POSIXct("2012-01-01 00:00:00"), as.POSIXct("2012-01-06 03:00:00"), by="hour")
  plot &lt;- (time_series, xlim = xlim, type='l')
  </code></pre>
  
  <p>but this is not working but results in <strong>Error in plot.window(...) : invalid 'xlim' value</strong>.</p>
  
  <p>Trying the following results in the same error:</p>
  
  <pre><code>xlim &lt;- c(as.POSIXct("2012-01-01 00:00:00"), as.POSIXct("2012-01-05 00:00:00"))
  </code></pre>
  
  <p>From the documentation I know that xlim has to be numeric and can be set like xlim = c(0,100) but how does it work when using xts data?</p>
  
  <p><strong>Edit</strong>: I know that this question is similar to the question <a href="https://stackoverflow.com/questions/16164989/time-series-plot-range?rq=1">Time series plot range</a>. However, as I don't know the data that needs to be plotted in the future I am interested in this particular solution.</p>