title: R: How to show forecast and actual data in a single plot?
body: <p>I have some timeseries data for 2000-Q1 to 2010-Q4. I have used the data from 2000-Q1 to 2008-Q2 to forecast the next 10 quarters using HoltWinters</p>
  
  <pre><code>CPI.HI.fit &lt;- HoltWinters(CPI.HI.pre, gamma=FALSE)
  CPI.HI.cfr &lt;- forecast(CPI.HI.fit, 10)
  </code></pre>
  
  <p>Here're the data--</p>
  
  <ol>
  <li><code>CPI.HI.pre</code> (previous timeseries of the <code>ts</code> class)</li>
  <li><code>CPI.HI.pos</code> (posterior timeseries of the <code>ts</code> class)</li>
  <li><code>CPI.HI.cfr</code> (crisis forecast of the <code>forecast</code> class)</li>
  </ol>
  
  <pre><code>&gt; CPI.HI.pre
  #          Qtr1     Qtr2     Qtr3     Qtr4
  # 2000 83.12262 83.72945 84.10338 84.58881
  # 2001 85.03111 85.92120 85.86388 85.74424
  # 2002 86.01310 86.89452 87.05565 87.31702
  # 2003 87.93231 88.23959 88.43708 88.56572
  # 2004 89.02891 90.05139 90.17285 90.68677
  # 2005 90.82155 91.74464 92.18774 92.57043
  # 2006 92.91782 94.15888 94.58178 94.13807
  # 2007 94.58282 95.99794 96.12194 97.08308
  # 2008 97.72470 99.54615                  
  &gt; CPI.HI.pos
  #           Qtr1      Qtr2      Qtr3      Qtr4
  # 2008                     100.39960  99.11151
  # 2009  98.79588  99.36900  99.75832  99.90321
  # 2010 100.17990 100.96250 100.99250 101.40690
  &gt; CPI.HI.cfr
  #         Point Forecast     Lo 80    Hi 80     Lo 95    Hi 95
  # 2008 Q3       99.86646  99.26724 100.4657  98.95002 100.7829
  # 2008 Q4      100.69200  99.93567 101.4483  99.53529 101.8487
  # 2009 Q1      101.51754 100.57777 102.4573 100.08028 102.9548
  # 2009 Q2      102.34308 101.19808 103.4881 100.59195 104.0942
  # 2009 Q3      103.16862 101.79962 104.5376 101.07492 105.2623
  # 2009 Q4      103.99416 102.38447 105.6038 101.53236 106.4560
  # 2010 Q1      104.81970 102.95412 106.6853 101.96654 107.6729
  # 2010 Q2      105.64524 103.50968 107.7808 102.37918 108.9113
  # 2010 Q3      106.47077 104.05204 108.8895 102.77163 110.1699
  # 2010 Q4      107.29631 104.58191 110.0107 103.14499 111.4476
  </code></pre>
  
  <p>I am able to get the previous data and forecast in one plot with</p>
  
  <pre><code>&gt; autoplot(CPI.HI.cfr)
  </code></pre>
  
  <p><img src="https://i.imgur.com/SUBR9S6.png" alt="the previous and forecast plots"></p>
  
  <p>and also the actual data for the forecast period in a separate plot with</p>
  
  <pre><code>&gt; autoplot(CPI.HI.pos)
  </code></pre>
  
  <p><img src="https://i.imgur.com/9D4q9d9.png" alt="the posterior plot"></p>
  
  <p>I want both of them together on the same plot.</p>
  
  <p>I understand it can be best done with <code>ggplot()</code> but after trying several ways
  such as</p>
  
  <pre><code>ggplot(aes(x=x, y=y), data=CPI.HI.pre) + 
    geom_line(CPI.HI.pos)
  </code></pre>
  
  <p>things started looked confusing to me !</p>