title: Plotting a spline function with ggplot2
body: <p>I want to plot a spline function with ggplot2. When I use this:</p>
  
  <pre><code>library(ggplot2)
  
  spline_x &lt;- 1:6
  spline_y &lt;- c(0, 0.5, 2, 2, 0.5, 0)
  spl_fun &lt;- splinefun(spline_x, spline_y)
  
  p &lt;- ggplot()
  p + stat_function(fun = spl_fun) + xlim(min(spline_x), max(spline_x)) + ylim(min(spline_y), max(spline_y))
  </code></pre>
  
  <p>I get an empty plot. The same thing with plot() works:</p>
  
  <pre><code>plot(spl_fun,
       xlim = c(min(spline_x), max(spline_x)),
       ylim = c(min(spline_y) - 1, max(spline_y) + 1)
      )
  </code></pre>
  
  <p>As an aside, how do I split the line with <code>stat_function</code> over multiple lines? If I just enter newlines (like in the <code>plot()</code> example), it (of course) stops evaluating after the call to <code>stat_function</code> and doesn't consider the x/ylim any more.</p>